2015-12-16 11:55 GMT+01:00 Jonas Maebe <jonas.ma...@elis.ugent.be>: > > Santiago A. wrote on Wed, 16 Dec 2015: > > In functions blockread and blockwrite, the result parameter is "var". >> And in blockread buffer is also "var". >> >> Couldn't they be marked as "out" instead of "var"?. >> > > The result parameters can be changed. The BlockRead buffer parameter > cannot be changed for the same reason that the parameters of fillchar and > move cannot be changed: it changes the behaviour in case a managed type, or > e.g. a record or array containing managed types, it passed. With "var", > nothing special happens, while with "out", they are first finalised. If > they are not yet initialised at that point (e.g. because they are the > result of a plain getmem), this would introduce crashes. > > Even though you cannot just blockread/blockwrite managed types anyway > (since they are pointers), this can currently work if you ensure that all > read/written managed types are nil. It may seem unlikely, but at least > changing the "var" parameters of move/fillchar to "out" even caused crashes > in the compiler because the RTL relies on the current behaviour (and using > move/fillchar with managed types is not very common/recommended either in > the general case). >
Thank you Jonas for this answer. This has been frustrating me, at least now I have an idea why. Now what I should do is add {%H-} on each line containing blockread, blockwrite, fillchar and so on... This isn't so difficult, after all. The only drawback is that it could potentially hide another perfectly valid warning. -- Frederic Da Vitoria (davitof) Membre de l'April - « promouvoir et défendre le logiciel libre » - http://www.april.org
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal