EGCS 1.1b C++ typeof/__typeof oddities

Ian R. Justman ianj@chocobo.org
Sun Nov 15 17:19:00 GMT 1998


Hello.

I am having a hard time compiling a package written in C++ on my Slackware
Linux 3.5 system, which unlike many distributions nowadays, is still based
on libc5.  The compiler suite I am using is EGCS 1.1b which I bootstrapped
from source.  I did a little bit of sleuthing and here's what I came up
with:

The package is called "wvdial".

Here are the errors/warnings the compiler generates:

wvpipe.cc: In method `bool WvPipe::child_killed() const':
wvpipe.cc:181: `st' undeclared (first use this function)
wvpipe.cc:181: (Each undeclared identifier is reported only once
wvpipe.cc:181: for each function it appears in.)
wvpipe.cc:181: warning: ANSI C++ forbids declaration `__in' with no type
wvpipe.cc:181: warning: ANSI C++ forbids declaration `__in' with no type
wvpipe.cc:182: warning: ANSI C++ forbids declaration `__in' with no type
wvpipe.cc: In method `int WvPipe::exit_status() const':
wvpipe.cc:191: `st' undeclared (first use this function)
wvpipe.cc:191: warning: ANSI C++ forbids declaration `__in' with no type
wvpipe.cc:191: warning: ANSI C++ forbids declaration `__in' with no type
wvpipe.cc:193: warning: ANSI C++ forbids declaration `__in' with no type
wvpipe.cc:195: warning: ANSI C++ forbids declaration `__in' with no type


Here is the code which it seems to have trouble with:

// if child_exited(), return true if it died because of a signal, or
// false if it died due to a call to exit().
bool WvPipe::child_killed() const
{
    int st = estatus;
    assert (WIFEXITED(st) || WIFSIGNALED(st));
    return WIFSIGNALED(st);
}


// return the numeric exit status of the child (if it exited) or the
// signal that killed the child (if it was killed).
int WvPipe::exit_status() const
{
    int st = estatus;
    assert (WIFEXITED(st) || WIFSIGNALED(st));
    if (child_killed())
        return WTERMSIG(st);
    else
        return WEXITSTATUS(st);
}

Here is the output of the preprocessor:

bool WvPipe::child_killed() const
{
    int st = estatus;
    ((void) (( ((( (__extension__ ({ union { __typeof(  st  ) __in; int __i; } __u;	__u.__in = (  st  ); __u.__i; }))  ) & 0xff) == 0)   || (((unsigned int)(( (__extension__ ({ union { __typeof(  st  ) __in; int __i; } __u;	__u.__in = (  st  ); __u.__i; }

))  )-1) & 0xFFFF) < 0xFF)   ) ||	(__assert_fail ("((((__extension__ ({ union { __typeof(st) __in; int __i; } __u; __u.__in = (st); __u.__i; }))) & 0xff) == 0) || (((unsigned int)(((__extension__ ({ union { __typeof(st) __in; int __i; } __u; __u.__in = (s

t); __u.__i; })))-1) & 0xFFFF) < 0xFF)" ,	"wvpipe.cc", 181, __PRETTY_FUNCTION__ ), 0))) ;
    return (((unsigned int)(( (__extension__ ({ union { __typeof(  st  ) __in; int __i; } __u;	__u.__in = (  st  ); __u.__i; }))  )-1) & 0xFFFF) < 0xFF)  ;
}


 
 
int WvPipe::exit_status() const
{
    int st = estatus;
    ((void) (( ((( (__extension__ ({ union { __typeof(  st  ) __in; int __i; } __u;	__u.__in = (  st  ); __u.__i; }))  ) & 0xff) == 0)   || (((unsigned int)(( (__extension__ ({ union { __typeof(  st  ) __in; int __i; } __u;	__u.__in = (  st  ); __u.__i; }

))  )-1) & 0xFFFF) < 0xFF)   ) ||	(__assert_fail ("((((__extension__ ({ union { __typeof(st) __in; int __i; } __u; __u.__in = (st); __u.__i; }))) & 0xff) == 0) || (((unsigned int)(((__extension__ ({ union { __typeof(st) __in; int __i; } __u; __u.__in = (s

t); __u.__i; })))-1) & 0xFFFF) < 0xFF)" ,	"wvpipe.cc", 191, __PRETTY_FUNCTION__ ), 0))) ;
    if (child_killed())
	return (( (__extension__ ({ union { __typeof(  st  ) __in; int __i; } __u;	__u.__in = (  st  ); __u.__i; }))  ) & 0x7f)  ;
    else
	return ((( (__extension__ ({ union { __typeof(  st  ) __in; int __i; } __u;	__u.__in = (  st  ); __u.__i; }))  ) & 0xff00) >> 8)  ;
}

I've verified the output of this under both the stock compiler, EGCS
1.0.3, and 1.1b.  Except for the different compiler-specific directories
and extra newlines in the full output files, there are no differences
between the two output files I generated.  EGCS 1.0.3 will compile this
code properly; 1.1b generates the errors I pointed out above.

As best I can figure, there are several __typeof constructs in libc5's
/usr/include/sys/wait.h, spedifically, the __WAIT_INT macro, which seem to
be causing the C++ compiler to choke.  I draw that conclusion based on the
fact that I see that the compiler is trying to get the type of st in the
preprocessor and from the error messages.

The specifics of my system:

Slackware Linux 3.5
Kernel upgraded to 2.0.35
libc 5.4.46, upgraded from 5.4.44
wvdial 1.20 (the package which seems to make the error easier to spot; its
  home page is http://www.worldvisions.ca/wvdial/ )

Let me know if you need anything else.

--Ian.

-----
Ian R. Justman 	         Postmaster, System Administrator, ChocoboNet
ianj@chocobo.org (home)  ianj@calweb.com (work)  NIC handle:  IJ12

Try EsperNet IRC!  Small and personal! 
irc.esper.net takes you to a random server
Admin of chocobo.esper.net, ports 5555, 6666-6669, 7000, Nick:  "IJ"
EsperNet Postmaster

I use Linux and FreeBSD, the ultimate "pane" relievers on the PC.
My heart AIX for a faster RS/6000
"MCSE = Must Consult Someone Experienced"  --Seen in someone's .sig

Hard Disk: n:  Future windchimes




More information about the Gcc-bugs mailing list