x = ++x + ++x

Manuel López-Ibáñez manuellopezibanez@yahoo.es
Tue Feb 19 05:15:00 GMT 2008


Diego Novillo wrote:
> On 2/15/08 8:43 AM, Eljay Love-Jensen wrote:
> 
>> Any guidance as to how I could accomplish this feat with GCC?
> 
> The code that checks for these sequence point problems in the C parser 
> is in c-common.c:warn_for_collisions.  You could do one of two things:
> 
> - Change the warning() call to error() or pedwarn() (so -pedantic causes 
> a compilation failure).
> 
> - Modify warn_for_collisions to return an indicator so the caller can 
> insert a call to abort() to cause the program to fail at runtime.
> 

In principle, for GCC >= 4.2, there is no need to modify GCC or even 
read the source code. You could use -fdiagnostics-show-option to find 
out which option generated the warning (my guess -Wsequence-point). 
Then, you can use -Werror=sequence-point to convert warnings generated 
by that option into an error and -Wfatal-errors to make the error fatal.

However, there is a bug here (any warning that is enabled/disabled by a 
switch but does not show that switch with -fdiagnostics-show-option is a 
bug). It is a trivial fix, so I hope I can sneak it into GCC 4.3.

Cheers,

	Manuel.



More information about the Gcc-help mailing list