A bug or two
Martin v. Loewis
martin@loewis.home.cs.tu-berlin.de
Fri Dec 31 20:54:00 GMT 1999
> (This program is not computer-science elegant. Sorry, it just grew.)
Thanks for your bug report. It is worse than being not elegant - it is
incorrect. In the C language, there is no guarantee that variables are
allocated on increasing addresses. So when you do
memset( &beginVarianceData, 0, &endVarianceData - &beginVarianceData );
you invoke what the standard calls "undefined behaviour". The compiler
might do anything with it: It could refuse to compile it, generate
code that does not work as you expect (as it does), or destroy your
microwave oven.
To use it with gcc, you probably have to fix it. I don't know what
other hidden treasures it has; the part with begin/end pairs is best
fixed by putting structures around these variables.
Regards,
Martin
More information about the Gcc-bugs
mailing list