This is the mail archive of the gcc-bugs@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]

[Bug c++/56815] void pointer arithmetic


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

--- Comment #22 from Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> 2013-04-04 10:38:06 UTC ---
(In reply to comment #21)
> Manuel, I'm adding the LangEnabledBy, to match the documentation. Thanks.
> 
> Now, I'm not sure to understand the existing lines (many):
> 
>   pedantic ? OPT_Wpedantic : OPT_Wpointer_arith
> 
> Do they imply that with -Wpedantic and -Wno-pointer-arith we emit such warnings
> anyway? Is this intended?

I think that is a relic from the past, and it is a bug that -Wno-pointer-arith
does not disable the warning.

I think the intended meaning is that the warnings are controlled by
-Wpointer-arith and -Wpointer-arith is enabled by -Wpedantic, so the above
should simply be warning_at(loc, OPT_Wpointer_arith,) and the following should
work after adding the LangEnabledBy():

-Wpedantic -> warn
-Wpointer-arith -> warn
-Wpedantic -Wno-pointer-arith -> nothing
-Werror=pedantic  -> error
-Wpedantic -Werror=pointer-arith -> error
-Werror=pedantic -Wno-error=pointer-arith -> warn

The problem with warnings enabled by -Wpedantic (such as Wlong-long) is that
they have further special conditions that are not trivial to represent in the
.opt files. In this case, there is:

void
c_common_init_options_struct (struct gcc_options *opts)
{
  opts->x_flag_exceptions = c_dialect_cxx ();
  opts->x_warn_pointer_arith = c_dialect_cxx ();
  opts->x_warn_write_strings = c_dialect_cxx ();
  opts->x_flag_warn_unused_result = true;

  /* By default, C99-like requirements for complex multiply and divide.  */
  opts->x_flag_complex_method = 2;
}

so the warning seems to be enabled by default in C++ (which is not documented
in invoke.texi!). It would be nice to encode this initializations directly in
the .opt file but I guess it should work ok as it is right now (it depends when
this init is called, before or after setting the command-line flags).

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