This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Why is -fstrict-aliasing excluded from function "optimize" attribute?


Hello,
I came across an issue with function "optimize" attribute. The code is like:
__attribute__((optimize("-fno-strict-aliasing")))
void foo()
{
   ...
}

When compiling with -O2, we expect this function is compiled without following
strict aliasing rule, whereas other code does. However, I found this function still
has strict aliasing flag turned on during compilation. After a little investigation,
I found the following lines of code in parse_optimize_options of c-common.c 
(4.5, 4.6 is similar)

...
  saved_flag_strict_aliasing = flag_strict_aliasing;

  /* Now parse the options.  */
  decode_options (opt_argc, opt_argv);

  targetm.override_options_after_change();

  /* Don't allow changing -fstrict-aliasing.  */
  flag_strict_aliasing = saved_flag_strict_aliasing;
...

-fstrict-aliasing is excluded from function specific optimize option. I checked
both internal manual and gcc manual. It seems not to be documented. I wonder
whether there is a good reason for this? If yes, at least we should document it.
BTW, the code certainly works in 4.4.

Regards,
Bingfeng Mei


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]