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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|minor                       |enhancement

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #6)
> Try:
> int
> foo ()
> {
>   static int a;
>   static const int b = 3;
>   static const char c[3] = "ab";
>   static const char *d = "cd";
>   static const char *const e = "ef";
>   return 1 * __builtin_constant_p (&a)
>          + 2 * __builtin_constant_p (&b)
>          + 4 *__builtin_constant_p (c)
>          + 8 * __builtin_constant_p (c[0])
>          + 16 *__builtin_constant_p (d)
>          + 32 * __builtin_constant_p (d[0])
>          + 64 *__builtin_constant_p (e)
>          + 128 * __builtin_constant_p (e[0]);
> }

What we get now is dependent on the optimization level and if it is C or C++
mode and even what version of the compiler (GCC 8+ has stablized it seems
though).
GCC 8+:
        -O0     -O1+
c         0     232 (8+32+64+128)
c++      64     232

GCC 6/7:
c         0     168 (8+32+128)
c++      64     232

GCC 4.5-5.x:
c/c++     0     168

GCC ???-4.4.x:
c         0     200 (128+64+8)
c++       0     136 (128+8)

4.1.2:
c         0     64
c++       0     128

clang:
c       192     232
c++11+  200     232
c++98   192     232

192 = 128+64; 200 = 128+64+8

Reply via email to