WIFEXITED() doesn't compile

Aaron Digulla digulla@wi-pc44.fh-konstanz.de
Tue Oct 6 07:54:00 GMT 1998


Setup: Linux 2.0.35, libc5, egcs-1.1

This code produces the bug:

------------------- bug.cc ---------------------------------------
void
test (void)
{
    int stat_loc = 0;
    (//__extension__    // This doesn't matter
    ({
	union
	{
	    __typeof__ (stat_loc) __in; // ERROR: `stat_loc' undeclared (first use this function)
	    //int __in;     // This works
	    int 		__i;
	} __u;
	__u.__in = (stat_loc);
	__u.__i;
    })
    );
}
------------------- bug.cc ---------------------------------------

Just compile with g++ -c bug.cc. This should produce the following output:

bug.cc: In function `void test()':
bug.cc:9: `stat_loc' undeclared (first use this function)
bug.cc:9: (Each undeclared identifier is reported only once
bug.cc:9: for each function it appears in.)
bug.cc:9: warning: ANSI C++ forbids declaration `__in' with no type

The original code was:

    ...
    int stat_loc;
    ...
    if (WIFEXITED(stat_loc)...

Interestingly enough, stat_loc is just unknown in the __typeof__. If
you add "int stat_loc;" in the line above the __typeof__, then you
get:

bug.cc: In function `void test()':
bug.cc:9: warning: declaration of identifier `stat_loc' as `int stat_loc'
bug.cc:4: warning: conflicts with other use in class as `int stat_loc'

so stat_loc is known inside the union.

--
Dipl. Inf. (FH) Aaron "Optimizer" Digulla     Assistent im BIKS Labor, FB WI
"(to) optimize: Make a program faster by      FH Konstanz, Brauneggerstr. 55
improving the algorithms rather than by       Tel:+49-7531-206-514
buying a faster machine."                     EMail: digulla@fh-konstanz.de



More information about the Gcc-bugs mailing list