[Bug preprocessor/35301] Function macro nesting depth appears to be uncomfortably limited.

pinskia at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Sat Feb 23 03:46:00 GMT 2008



------- Comment #1 from pinskia at gcc dot gnu dot org  2008-02-23 03:45 -------
I think this is correct CPP behavior.
it only evaluates one level of _ .

Think of:
#define a b
#define b a
b
a

What does that do?
it just does:
b
a

Instead of causing an infinite loop.

Once we try to revaluate _ again after evaluating it once from the macro
expansion, CPP no longer evaluates it again.
So the first time we expand xmallocq, we get _( progn ... , _(exssert_nexpr,
...) ) and then
we expand the two _(, we get:
progn(..., exssert_nexpr(...) ) and new expands progn and exssert_nexpr, we
get:

        ({void *gensym = malloc(2000000000); _(exssert_with_epilogue_nexpr,
gensym == ((void *)0), (), "malloc returned NULL at: %s:%s, line %d","t.c",
__FUNCTION__, 27); gensym;});


And then since we already used _(x, ...), CPP can no longer expand anything so
it stops.


-- 


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



More information about the Gcc-bugs mailing list