The following code snippet triggers the assert.

Interestingly, the exact message that you get depends on the gcc version. 2.9x
gives you a "6+1 != 6" message, where 3.x gives you a "7+1 != 7".

On gcc3.3.5:
silly: sillytest.c:7: main: Assertion `((7) + 1 == (7))' failed.
Aborted

The code is as follows.

#include <assert.h>
#define macro(a, b) ((a) + 1 == (b))
int
main(void)
{
       assert(macro(__LINE__
                , __LINE__));
       return 0;
}

You're not alone - the only compiler I've found that does what I expect is the
SunWorkshop Pro compiler. Pretty much all the rest mess up somewhere along the 
line!

Cheers,

David

-- 
           Summary: __LINE__ implementation flaky.
           Product: gcc
           Version: 3.3.5
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: preprocessor
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: david dot pye at osm dot co dot uk
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20262

Reply via email to