This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/38397] New: gcc -E -dD changes the meaning of source
- From: "algrant at acm dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 4 Dec 2008 12:19:15 -0000
- Subject: [Bug c/38397] New: gcc -E -dD changes the meaning of source
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
compile with -E -dD:
enum { A, B };
#define B A
#define A B+1
int x = A;
This will print something like
enum { A, B };
#define B A
#define A B+1
int x = A+1;
This defines x as 2 instead of 1. Recycle the output bad in and
x gets bigger and bigger.
Although it doesn't seem to be formally defined that the output
of -E -dD is valid source code equivalent to the original,
the output is presented as if it is. There are at least two
solutions:
- present the #define and #undef as comments
- suppress macro expansion when -dD is used
The ability to suppress macro expansion is a useful feature in
its own right and could make some sources more readable, when the
intention of -E is simply to flatten the input.
--
Summary: gcc -E -dD changes the meaning of source
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: algrant at acm dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38397