https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81156

--- Comment #1 from joseph at codesourcery dot com <joseph at codesourcery dot 
com> ---
Different OSes (and sometimes different compilers) have different tgmath.h 
implementations.  Those implementations typically expand calls to tgmath.h 
macros to expansions that repeat their arguments many times.

You have sqrt(pow(sqrt(pow()))).  In glibc's tgmath.h, pow expands to 
repeat each of its arguments 58 times, and sqrt repeats each of its 
arguments 57 times.  So you have 58*57*58*57 = 10929636 repetitions of 
each of the arguments to each of the inner pow calls, even before 
accounting for all of the other text in there, and all those tokens need 
to be generated and parsed even though most of it ends up getting folded 
away eventually.  I expect in principle your code could compile given 
enough memory and time, but "enough" might be very large.

Maybe I should implement __builtin_tgmath to allow macros that expand each 
argument once only, which is clearly best for such macros to allow deeply 
nested calls.  (My inclination is to prefer a smart __builtin_tgmath that 
can be used for all tgmath.h macros, instead of several dumber variants 
such as I previously suggested in projects/c-frontend.html; it would be 
desirable for it to be able to handle TS 18661-1 functions that round 
result to narrower type and TS 18661-3 types as well.  Such builtins would 
probably be necessary for implementing TS 18661-5 
__STDC_TGMATH_OPERATOR_EVALUATION__.)

Reply via email to