On Wed, 5 Jun 2013, Jakub Jelinek wrote:

> On Wed, Jun 05, 2013 at 11:44:07AM -0700, Andrew Pinski wrote:
> > On Wed, Jun 5, 2013 at 10:57 AM, Marek Polacek <pola...@redhat.com> wrote:
> > > Comments, please?
> > I think it might be better to do handle this while gimplification
> > happens rather than while parsing.  The main reason is that constexpr
> > might fail due to the added function calls.
> 
> Gimplification is too late, the FEs perform various operation shortenings
> etc. in many cases, and what exactly is undefined behavior is apparently
> heavily dependent on the particular language (C has different rules from
> C++).  Yes, constexpr is something to consider in this light, but not
> something that can't be handled (recognizing ubsan builtins and just
> handling them specially).

Agreed, this needs handling before folding and other optimizations in the 
front ends to have predictable results.

It may make sense to try running the whole testsuite with this option, 
minus tests of -fwrapv, to make sure it doesn't break any corner cases of 
valid tests (of course it may well show up some invalid tests).  In 
particular, gcc.dg/*const-expr* and gcc.dg/overflow-warn*.  Generating 
extra diagnostics for code in those tests that already gets a diagnostic 
is OK, as long as it doesn't generate diagnostics for non-overflow cases 
in those tests that aren't meant to be treated as overflow, or lose 
diagnostics for cases that are required to be diagnosed.

-- 
Joseph S. Myers
jos...@codesourcery.com

Reply via email to