public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* preprocessor/3049: Conditional compilation using "#if A==B" broken on i386 Red Hat 7.0.
@ 2001-06-04 14:16 behanna
  0 siblings, 0 replies; 3+ messages in thread
From: behanna @ 2001-06-04 14:16 UTC (permalink / raw)
  To: gcc-gnats

>Number:         3049
>Category:       preprocessor
>Synopsis:       Conditional compilation using "#if A==B" broken on i386 Red Hat 7.0.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 04 14:16:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Chris BeHanna <behanna@zbzoom.net>
>Release:        gcc version 2.96 20000731 (Red Hat Linux 7.0)
>Organization:
>Environment:
output of uname -a:
Linux sunflower 2.2.16-22smp #1 SMP Tue Aug 22 16:39:21 EDT 2000 i686 unknown
>Description:
Specifically, code that is conditionally compiled using
#if BYTE_ORDER == BIG_ENDIAN
// stuff
#endif
#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
// stuff
#endif

results in both sections of code getting processed on Red Hat 7.0 if _XOPEN_SOURCE is defined.  The problem does not occur if _XOPEN_SOURCE is not defined.  The attached program reproduces this problem.
>How-To-Repeat:
Compile the attached program with g++ 2.96 20000731 on Red Hat 7.0 PC with the following command:

g++ -D_XOPEN_SOURCE -o t t.cpp

Execute it.  The output will be

big endian
little endian or PDP endian

(i.e., both sections of code are compiled instead of only the LITTLE_ENDIAN section).

As you might expect, this completely prevents any code that includes <arpa/nameser_compat.h> from being able to compile.
>Fix:
I honestly don't know.  If I have time, I'll dig into the source and see if there's anything obvious, and submit a patch.
>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: preprocessor/3049: Conditional compilation using "#if A==B"broken on i386 Red Hat 7.0.
@ 2001-06-04 16:06 Chris BeHanna
  0 siblings, 0 replies; 3+ messages in thread
From: Chris BeHanna @ 2001-06-04 16:06 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR preprocessor/3049; it has been noted by GNATS.

From: Chris BeHanna <behanna@zbzoom.net>
To: Neil Booth <neil@daikokuya.demon.co.uk>
Cc: <gcc-gnats@gcc.gnu.org>
Subject: Re: preprocessor/3049: Conditional compilation using "#if A==B"
 broken on i386 Red Hat 7.0.
Date: Mon, 4 Jun 2001 19:02:32 -0400 (EDT)

 On Mon, 4 Jun 2001, Neil Booth wrote:
 
 > behanna@zbzoom.net wrote:-
 >
 > > #if BYTE_ORDER == BIG_ENDIAN
 > > // stuff
 > > #endif
 > > #if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
 > > // stuff
 > > #endif
 >
 > > results in both sections of code getting processed on Red Hat 7.0 if
 > > _XOPEN_SOURCE is defined.  The problem does not occur if _XOPEN_SOURCE
 > > is not defined.  The attached program reproduces this problem.
 >
 > That raises the obvious question: can you tell me what are the values
 > of BIG_ENDIAN, LITTLE_ENDIAN, BYTE_ORDER and PDP_ENDIAN when you
 > define _XOPEN_SOURCE?  (e.g. put them through a printf).
 >
 > I'd be extremely suprised if this is a CPP bug, but if it is we need
 > to fix it quickly.
 
     The test program won't even compile with the following lines added
 after the last #endif and -D_XOPEN_SOURCE on the compile line:
 
   cout << "BIG_ENDIAN    = " << BIG_ENDIAN << endl;
   cout << "LITTLE_ENDIAN = " << LITTLE_ENDIAN << endl;
   cout << "PDP_ENDIAN    = " << PDP_ENDIAN << endl;
   cout << "BYTE_ORDER    = " << BYTE_ORDER << endl;
 
 I get the following errors:
 
 /home/cbehanna/t.cpp: In function `int main (int, char **)':
 /home/cbehanna/t.cpp:15: `BIG_ENDIAN' undeclared (first use this
 function)
 /home/cbehanna/t.cpp:15: (Each undeclared identifier is reported only
 once for each function it appears in.)
 /home/cbehanna/t.cpp:16: `LITTLE_ENDIAN' undeclared (first use this
 function)
 /home/cbehanna/t.cpp:17: `PDP_ENDIAN' undeclared (first use this
 function)
 /home/cbehanna/t.cpp:18: `BYTE_ORDER' undeclared (first use this
 function)
 
 It of course compiles just fine if -D_XOPEN_SOURCE is omitted.
 
     This explains why both sections of code are executed:  they
 effectively evaluate to #if 0 == 0.
 
     In endian.h, we find the following:
 
     #ifdef  __USE_BSD
     # define LITTLE_ENDIAN  __LITTLE_ENDIAN
     # define BIG_ENDIAN __BIG_ENDIAN
     # define PDP_ENDIAN __PDP_ENDIAN
     # define BYTE_ORDER __BYTE_ORDER
     #endif
 
 Of course, __USE_BSD is not defined when _XOPEN_SOURCE is defined.
 This breaks a lot of things, not just endian.h.  Looks like Red Hat
 screwed the pooch.
 
     I suppose it would make sense at this point to report this to Red
 Hat and close out the PR.  Sorry about that.
 
 -- 
 Chris BeHanna
 Software Engineer                   (Remove "bogus" before responding.)
 behanna@bogus.zbzoom.net
 I was raised by a pack of wild corn dogs.
 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: preprocessor/3049: Conditional compilation using "#if A==B" broken on i386 Red Hat 7.0.
@ 2001-06-04 15:36 Neil Booth
  0 siblings, 0 replies; 3+ messages in thread
From: Neil Booth @ 2001-06-04 15:36 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR preprocessor/3049; it has been noted by GNATS.

From: Neil Booth <neil@daikokuya.demon.co.uk>
To: behanna@zbzoom.net
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: preprocessor/3049: Conditional compilation using "#if A==B" broken on i386 Red Hat 7.0.
Date: Mon, 4 Jun 2001 23:35:06 +0100

 behanna@zbzoom.net wrote:-
 
 > #if BYTE_ORDER == BIG_ENDIAN
 > // stuff
 > #endif
 > #if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
 > // stuff
 > #endif
 
 > results in both sections of code getting processed on Red Hat 7.0 if
 > _XOPEN_SOURCE is defined.  The problem does not occur if _XOPEN_SOURCE
 > is not defined.  The attached program reproduces this problem.
 
 That raises the obvious question: can you tell me what are the values
 of BIG_ENDIAN, LITTLE_ENDIAN, BYTE_ORDER and PDP_ENDIAN when you
 define _XOPEN_SOURCE?  (e.g. put them through a printf).
 
 I'd be extremely suprised if this is a CPP bug, but if it is we need
 to fix it quickly.
 
 Neil.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-06-04 16:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-04 14:16 preprocessor/3049: Conditional compilation using "#if A==B" broken on i386 Red Hat 7.0 behanna
2001-06-04 15:36 Neil Booth
2001-06-04 16:06 preprocessor/3049: Conditional compilation using "#if A==B"broken " Chris BeHanna

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).