[C++ Patch] PR 50810 (new try)

Gabriel Dos Reis gdr@integrable-solutions.net
Mon Oct 24 17:47:00 GMT 2011


On Mon, Oct 24, 2011 at 9:53 AM, Jason Merrill <jason@redhat.com> wrote:
> On 10/24/2011 10:39 AM, Gabriel Dos Reis wrote:
>>
>> Hmm, the narrowing semantics also affects SFINAE, not just simple
>> declaration.
>> If we want a flag that can also affect the outcome of overload
>> resolution, it should one of the the -fflags, such as -fpermissive.
>
> I don't want the option to affect SFINAE,

So, let me recap:

  1. narrowing conversion is ill-formed in C++11; therefore a diagnostic
     is required.  This has two implications:
      a.  "Normal" scenario: a diagnostic is required and the program rejected.
           This is the one people complain about.

      b.  SFINAE context: because the narrowing is ill-formed, the offernding
           expression (rather, the offending function) would just be silently
           ignored; no diagnostic is actually output.


  2. -Wnarrowing warns about narrowing conversion, but does not reject
     the code.  This is only for C++98, C++03, with -Wc++0x-compat

While 1.b. looks like -Wnarrowing in sfinae context, it is not -Wno-narrowing
because with -Wnarrowing we still accept the expression (as opposed to
rejecting.)
So, if you make -Wno-narrowing meaningful in C++11 mode then how can
it not affect sfinae (case 1.b.) and still be consistent with the
other case where
a diagnostic is required  the expression accepted?


> just suppress the diagnostic when
> tf_error is set.  There are a number of similar places in the compiler where
> if tf_error is set we give a pedwarn and accept the code, but if tf_error is
> not set we fail.



More information about the Gcc-patches mailing list