Stephen Horne
10/17/2008 6:28:00 AM
On Thu, 16 Oct 2008 05:43:04 -0400, Kai-Uwe Bux <jkherciueh@gmx.net>
wrote:
>I know. The compiler is required to issue a diagnostic and can then go on a
>compile anyway. But we know that the compiler compiles anyway; and that the
>code is not C++ is somewhat besides the point of why a segfault happens.
Probably agreed, but I'm confused. What is going on with that example,
exactly?
I tried compiling - GCC 3.4.5 didn't give me that required diagnostic
even with -Wall. All it told me about was a couple of unused
variables.
The obvious mistake is that fromLabels etc are not marked const. To be
honest, I was surprised that the use of those variables in what should
surely need to be constant expressions compiled at all.
Havn't tried VC++, but I'm pretty confident it will choke.
Adding the two missing const flags doesn't fix the segfault, so
assuming I'm on the right lines, I agree that it's irrelevant to the
problem at hand - especially as this is probably just a
hastily-prepared-simple-example thing.
I'd love to know what's going on, but surely it's just a
compiler-specific extension?
Being over-pedantic myself, I'm confident that compiler-specific
extensions aren't outlawed by the standard, so I don't see how their
use can make something "not C++". Not portable, of course, and
off-topic, but that's not the same thing.
BTW - I've looked in the GCC manual, but for some reason I can't find
the option to turn off all compiler-specific extensions. The dialect
section gives plenty of options, but they all seem to need me to know
which extension I want to turn off. Don't read the manual for me, of
course, but if anyone knows off the top of their head?