Joseph Myers <jos...@codesourcery.com> wrote:

> None of these are valid constant expressions as defined by the standard 
> (constant expressions cannot involve evaluated function calls).

That's why I ask specifically why GCC bugs on log(log(...)), but not on
log(sqrt(...) ...)!

GCC also accepts following initializers and places these constants in the
    .rodata section, i.e. it evaluates the functions during compile time:

const double pi = acos(-1.0);
const double pi_by_2 = acos(0.0);
const double pi_by_two = asin(1.0);
const double log_pi = log(acos(-1.0));
const double log_pi_by_2 = log(acos(0.0));
const double log_pi_by_two = log(asin(1.0));
const double sqrt_sqrt_2 = sqrt(sqrt(2.0));

Again: what's SOOO special about log(log(<constant expression>))? 

> Some might be accepted as an extension, but I expect that since the 
> optimization for constant arguments is intended for valid calls that
> would otherwise be executed at runtime, not for static initializers,
> it's avoiding optimizations that would result in the loss of floating-
> point exception flag raising.

That's no valid excuse: by the standard, the compiler is free to execute
static initializers during runtime, before calling the main() routine.

JFTR: doing so would but inhibit the placement of such constants in the
      read-only data section ... what is also allowed by the standard.

regards
Stefan

Reply via email to