public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/50810] New: c++0x-compat does not warn about narrowing conversions
@ 2011-10-20 13:41 public at alisdairm dot net
  2011-10-20 13:55 ` [Bug c++/50810] " redi at gcc dot gnu.org
                   ` (19 more replies)
  0 siblings, 20 replies; 21+ messages in thread
From: public at alisdairm dot net @ 2011-10-20 13:41 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 50810
           Summary: c++0x-compat does not warn about narrowing conversions
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: public@alisdairm.net


The following program is rejected by g++ in -std=c++0x mode (assuming 'char' is
signed) but does not raise any warnings when compiled with -Wc++0x-compat:


int main() {
   char data[] = { 0xff };
   char value = 0xff;
}


This is significantly the largest source of compatibility errors in our
code-base today (>95% of our known issues), so it would be very useful if the
warning caught these.


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug c++/50810] c++0x-compat does not warn about narrowing conversions
  2011-10-20 13:41 [Bug c++/50810] New: c++0x-compat does not warn about narrowing conversions public at alisdairm dot net
@ 2011-10-20 13:55 ` redi at gcc dot gnu.org
  2011-10-21 22:50 ` paolo.carlini at oracle dot com
                   ` (18 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: redi at gcc dot gnu.org @ 2011-10-20 13:55 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011-10-20
     Ever Confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-10-20 13:55:02 UTC ---
(In reply to comment #0)
> This is significantly the largest source of compatibility errors in our
> code-base today

yep, same here


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug c++/50810] c++0x-compat does not warn about narrowing conversions
  2011-10-20 13:41 [Bug c++/50810] New: c++0x-compat does not warn about narrowing conversions public at alisdairm dot net
  2011-10-20 13:55 ` [Bug c++/50810] " redi at gcc dot gnu.org
@ 2011-10-21 22:50 ` paolo.carlini at oracle dot com
  2011-10-21 22:57 ` paolo.carlini at oracle dot com
                   ` (17 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-21 22:50 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |paolo.carlini at oracle dot
                   |                            |com, redi at gcc dot
                   |                            |gnu.org

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-21 22:50:00 UTC ---
Note, this changed between 4.6 and 4.7 from permerror to pedwarn.

This said, check_narrowing is called by digest_init_r like this:

      if (cxx_dialect != cxx98 && nested)
    check_narrowing (type, init);

thus probably it would be easy to call it also when cxx_dialect is cxx98 &&
warn_cxx0x_compat and then, at the end, have something like:

  if (!ok)
    {
      if (cxx_dialect != cxx98)
        pedwarn (input_location, OPT_Wnarrowing, "narrowing conversion of %qE "
            "from %qT to %qT inside { }", init, ftype, type);
      else
        warning (OPT_Wc__0x_compat, "narrowing conversion of %qE "
            "from %qT to %qT inside { }", init, ftype, type);
    }

maybe with a slightly different message in the -Wc++0x-compat case.

Jason?


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug c++/50810] c++0x-compat does not warn about narrowing conversions
  2011-10-20 13:41 [Bug c++/50810] New: c++0x-compat does not warn about narrowing conversions public at alisdairm dot net
  2011-10-20 13:55 ` [Bug c++/50810] " redi at gcc dot gnu.org
  2011-10-21 22:50 ` paolo.carlini at oracle dot com
@ 2011-10-21 22:57 ` paolo.carlini at oracle dot com
  2011-10-22  1:15 ` manu at gcc dot gnu.org
                   ` (16 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-21 22:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-21 22:57:31 UTC ---
(detail: not sure about the 'if (!warn_narrowing) return;' at the beginning of
check_narrowing: probably we don't want -Wno-narrowing to suppress the warnings
enabled of -Wc++0x-compat)


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug c++/50810] c++0x-compat does not warn about narrowing conversions
  2011-10-20 13:41 [Bug c++/50810] New: c++0x-compat does not warn about narrowing conversions public at alisdairm dot net
                   ` (2 preceding siblings ...)
  2011-10-21 22:57 ` paolo.carlini at oracle dot com
@ 2011-10-22  1:15 ` manu at gcc dot gnu.org
  2011-10-22  1:25 ` manu at gcc dot gnu.org
                   ` (15 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: manu at gcc dot gnu.org @ 2011-10-22  1:15 UTC (permalink / raw)
  To: gcc-bugs

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

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu.org

--- Comment #4 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2011-10-22 01:15:14 UTC ---
(In reply to comment #3)
> (detail: not sure about the 'if (!warn_narrowing) return;' at the beginning of
> check_narrowing: probably we don't want -Wno-narrowing to suppress the warnings
> enabled of -Wc++0x-compat)

I think what you want is that -Wc++0x-compat enables -Wnarrowing independently
of -std=, but still -Wc++0x-compat -Wno-narrowing should disable it. See the
handling of Wlonglong in c-opts.c. So:

  if (!ok)
    {
      if (cxx_dialect != cxx98)
        pedwarn (input_location, OPT_Wnarrowing, "narrowing conversion of %qE "
            "from %qT to %qT inside { }", init, ftype, type);
      else
        warning_at (input_location, OPT_Wnarrowing, "narrowing conversion of
%qE "
            "from %qT to %qT inside { }", init, ftype, type);
    }

This approach also allows the user to specify -Wnarrowing to get the warnings
independently of -std=.


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug c++/50810] c++0x-compat does not warn about narrowing conversions
  2011-10-20 13:41 [Bug c++/50810] New: c++0x-compat does not warn about narrowing conversions public at alisdairm dot net
                   ` (3 preceding siblings ...)
  2011-10-22  1:15 ` manu at gcc dot gnu.org
@ 2011-10-22  1:25 ` manu at gcc dot gnu.org
  2011-10-22  4:38 ` jason at gcc dot gnu.org
                   ` (14 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: manu at gcc dot gnu.org @ 2011-10-22  1:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2011-10-22 01:24:25 UTC ---
(In reply to comment #4)
> (In reply to comment #3)
> > (detail: not sure about the 'if (!warn_narrowing) return;' at the beginning of
> > check_narrowing: probably we don't want -Wno-narrowing to suppress the warnings
> > enabled of -Wc++0x-compat)
> 
> I think what you want is that -Wc++0x-compat enables -Wnarrowing independently
> of -std=, but still -Wc++0x-compat -Wno-narrowing should disable it. See the
> handling of Wlonglong in c-opts.c. So:
> 
>   if (!ok)
>     {
>       if (cxx_dialect != cxx98)
>         pedwarn (input_location, OPT_Wnarrowing, "narrowing conversion of %qE "
>             "from %qT to %qT inside { }", init, ftype, type);
>       else
>         warning_at (input_location, OPT_Wnarrowing, "narrowing conversion of
> %qE "
>             "from %qT to %qT inside { }", init, ftype, type);
>     }
> 

You can even make this more compact by using emit_diagnostic:

emit_diagnostic ((cxx_dialect != cxx98) ? DK_PEDWARN : DK_WARNING,
                 input_location, OPT_Wnarrowing,
                 "narrowing conversion of %qE from %qT to %qT inside { }", 
                  init, ftype, type);

The C FE has wrappers around something similar called pedwarn_c99, that is, a
pedwarn in C99, otherwise just a warning. You could add something similar to
C++.


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug c++/50810] c++0x-compat does not warn about narrowing conversions
  2011-10-20 13:41 [Bug c++/50810] New: c++0x-compat does not warn about narrowing conversions public at alisdairm dot net
                   ` (4 preceding siblings ...)
  2011-10-22  1:25 ` manu at gcc dot gnu.org
@ 2011-10-22  4:38 ` jason at gcc dot gnu.org
  2011-10-22  9:19 ` paolo.carlini at oracle dot com
                   ` (13 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: jason at gcc dot gnu.org @ 2011-10-22  4:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> 2011-10-22 04:38:15 UTC ---
Makes sense to me.


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug c++/50810] c++0x-compat does not warn about narrowing conversions
  2011-10-20 13:41 [Bug c++/50810] New: c++0x-compat does not warn about narrowing conversions public at alisdairm dot net
                   ` (5 preceding siblings ...)
  2011-10-22  4:38 ` jason at gcc dot gnu.org
@ 2011-10-22  9:19 ` paolo.carlini at oracle dot com
  2011-10-23  0:37 ` paolo.carlini at oracle dot com
                   ` (12 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-22  9:19 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |paolo.carlini at oracle dot
                   |gnu.org                     |com

--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-22 09:18:12 UTC ---
Ok, thanks a lot Manuel and Jason, I can do this.


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug c++/50810] c++0x-compat does not warn about narrowing conversions
  2011-10-20 13:41 [Bug c++/50810] New: c++0x-compat does not warn about narrowing conversions public at alisdairm dot net
                   ` (6 preceding siblings ...)
  2011-10-22  9:19 ` paolo.carlini at oracle dot com
@ 2011-10-23  0:37 ` paolo.carlini at oracle dot com
  2011-10-23  2:08 ` jason at redhat dot com
                   ` (11 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-23  0:37 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|paolo.carlini at oracle dot |
                   |com                         |

--- Comment #8 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-23 00:36:25 UTC ---
I have the patch essentially ready. My only remaining doubt is that currently
-Wc++0x-compat is part of -Wall, and -Wnarrowing would become also part of
-Wall. Are we sure about this?


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug c++/50810] c++0x-compat does not warn about narrowing conversions
  2011-10-20 13:41 [Bug c++/50810] New: c++0x-compat does not warn about narrowing conversions public at alisdairm dot net
                   ` (7 preceding siblings ...)
  2011-10-23  0:37 ` paolo.carlini at oracle dot com
@ 2011-10-23  2:08 ` jason at redhat dot com
  2011-10-23  2:13 ` paolo.carlini at oracle dot com
                   ` (10 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: jason at redhat dot com @ 2011-10-23  2:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Jason Merrill <jason at redhat dot com> 2011-10-23 02:06:56 UTC ---
I think that makes sense, yes. People can always specify -Wno-narrowing if they
don't want it.

"paolo.carlini at oracle dot com" <gcc-bugzilla@gcc.gnu.org> wrote:

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|paolo.carlini at oracle dot |
                   |com                         |

--- Comment #8 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-23
00:36:25 UTC ---
I have the patch essentially ready. My only remaining doubt is that currently
-Wc++0x-compat is part of -Wall, and -Wnarrowing would become also part of
-Wall. Are we sure about this?


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug c++/50810] c++0x-compat does not warn about narrowing conversions
  2011-10-20 13:41 [Bug c++/50810] New: c++0x-compat does not warn about narrowing conversions public at alisdairm dot net
                   ` (8 preceding siblings ...)
  2011-10-23  2:08 ` jason at redhat dot com
@ 2011-10-23  2:13 ` paolo.carlini at oracle dot com
  2011-10-23 18:37 ` paolo.carlini at oracle dot com
                   ` (9 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-23  2:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-23 02:12:42 UTC ---
Great. I'll post the patch tomorrow.


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug c++/50810] c++0x-compat does not warn about narrowing conversions
  2011-10-20 13:41 [Bug c++/50810] New: c++0x-compat does not warn about narrowing conversions public at alisdairm dot net
                   ` (10 preceding siblings ...)
  2011-10-23 18:37 ` paolo.carlini at oracle dot com
@ 2011-10-23 18:37 ` paolo at gcc dot gnu.org
  2011-10-23 21:02 ` paolo at gcc dot gnu.org
                   ` (7 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: paolo at gcc dot gnu.org @ 2011-10-23 18:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2011-10-23 18:34:51 UTC ---
Author: paolo
Date: Sun Oct 23 18:34:45 2011
New Revision: 180343

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=180343
Log:
/c-family
2011-10-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/50810
    * c-opts.c (c_common_handle_option): Enable -Wnarrowing as part
    of -Wall; include -Wnarrowing in -Wc++0x-compat; adjust default
    Wnarrowing for C++0x and C++98.
    * c.opt ([Wnarrowing]): Update.

/cp
2011-10-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/50810
    * typeck2.c (check_narrowing): Adjust OPT_Wnarrowing diagnostics.
    (digest_init_r): Call check_narrowing irrespective of the C++ dialect.
    * decl.c (check_initializer): Likewise.
    * semantics.c (finish_compound_literal): Likewise.

/testsuite
2011-10-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/50810
    * g++.dg/cpp0x/warn_cxx0x2.C: New.
    * g++.dg/cpp0x/warn_cxx0x3.C: Likewise.

2011-10-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/50810
    * doc/invoke.texi ([-Wnarrowing], [-Wc++0x-compat]): Update.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/warn_cxx0x2.C
    trunk/gcc/testsuite/g++.dg/cpp0x/warn_cxx0x3.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-family/ChangeLog
    trunk/gcc/c-family/c-opts.c
    trunk/gcc/c-family/c.opt
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/semantics.c
    trunk/gcc/cp/typeck2.c
    trunk/gcc/doc/invoke.texi
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug c++/50810] c++0x-compat does not warn about narrowing conversions
  2011-10-20 13:41 [Bug c++/50810] New: c++0x-compat does not warn about narrowing conversions public at alisdairm dot net
                   ` (9 preceding siblings ...)
  2011-10-23  2:13 ` paolo.carlini at oracle dot com
@ 2011-10-23 18:37 ` paolo.carlini at oracle dot com
  2011-10-23 18:37 ` paolo at gcc dot gnu.org
                   ` (8 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-23 18:37 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.0

--- Comment #12 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-23 18:35:59 UTC ---
Done for 4.7.0.


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug c++/50810] c++0x-compat does not warn about narrowing conversions
  2011-10-20 13:41 [Bug c++/50810] New: c++0x-compat does not warn about narrowing conversions public at alisdairm dot net
                   ` (11 preceding siblings ...)
  2011-10-23 18:37 ` paolo at gcc dot gnu.org
@ 2011-10-23 21:02 ` paolo at gcc dot gnu.org
  2011-10-23 21:03 ` paolo.carlini at oracle dot com
                   ` (6 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: paolo at gcc dot gnu.org @ 2011-10-23 21:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #13 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2011-10-23 20:59:48 UTC ---
Author: paolo
Date: Sun Oct 23 20:59:43 2011
New Revision: 180348

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=180348
Log:
/c-family
2011-10-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/50841
    Revert:
    2011-10-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/50810
    * c-opts.c (c_common_handle_option): Enable -Wnarrowing as part
    of -Wall; include -Wnarrowing in -Wc++0x-compat; adjust default
    Wnarrowing for C++0x and C++98.
    * c.opt ([Wnarrowing]): Update.

/cp
2011-10-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/50841
    Revert:
    2011-10-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/50810
    * typeck2.c (check_narrowing): Adjust OPT_Wnarrowing diagnostics.
    (digest_init_r): Call check_narrowing irrespective of the C++ dialect.
    * decl.c (check_initializer): Likewise.
    * semantics.c (finish_compound_literal): Likewise.

/testsuite
2011-10-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/50841
    Revert:
    2011-10-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/50810
    * g++.dg/cpp0x/warn_cxx0x2.C: New.
    * g++.dg/cpp0x/warn_cxx0x3.C: Likewise.

2011-10-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/50841
    Revert:
    2011-10-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/50810
    * doc/invoke.texi ([-Wnarrowing], [-Wc++0x-compat]): Update.

Removed:
    trunk/gcc/testsuite/g++.dg/cpp0x/warn_cxx0x2.C
    trunk/gcc/testsuite/g++.dg/cpp0x/warn_cxx0x3.C
Modified:
    trunk/gcc/c-family/ChangeLog
    trunk/gcc/c-family/c-opts.c
    trunk/gcc/c-family/c.opt
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/semantics.c
    trunk/gcc/cp/typeck2.c
    trunk/gcc/doc/invoke.texi
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug c++/50810] c++0x-compat does not warn about narrowing conversions
  2011-10-20 13:41 [Bug c++/50810] New: c++0x-compat does not warn about narrowing conversions public at alisdairm dot net
                   ` (12 preceding siblings ...)
  2011-10-23 21:02 ` paolo at gcc dot gnu.org
@ 2011-10-23 21:03 ` paolo.carlini at oracle dot com
  2011-10-23 21:16 ` paolo at gcc dot gnu.org
                   ` (5 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-23 21:03 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |
         AssignedTo|paolo.carlini at oracle dot |unassigned at gcc dot
                   |com                         |gnu.org

--- Comment #14 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-23 21:02:36 UTC ---
Patch needs preliminary clean-ups in gcc/config, etc.


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug c++/50810] c++0x-compat does not warn about narrowing conversions
  2011-10-20 13:41 [Bug c++/50810] New: c++0x-compat does not warn about narrowing conversions public at alisdairm dot net
                   ` (13 preceding siblings ...)
  2011-10-23 21:03 ` paolo.carlini at oracle dot com
@ 2011-10-23 21:16 ` paolo at gcc dot gnu.org
  2011-10-23 21:44 ` manu at gcc dot gnu.org
                   ` (4 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: paolo at gcc dot gnu.org @ 2011-10-23 21:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #15 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2011-10-23 21:15:11 UTC ---
Author: paolo
Date: Sun Oct 23 21:15:08 2011
New Revision: 180349

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=180349
Log:
/c-family
2011-10-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/50841
    Revert:
    2011-10-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/50810
    * c-opts.c (c_common_handle_option): Enable -Wnarrowing as part
    of -Wall; include -Wnarrowing in -Wc++0x-compat; adjust default
    Wnarrowing for C++0x and C++98.
    * c.opt ([Wnarrowing]): Update.

/cp
2011-10-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/50841
    Revert:
    2011-10-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/50810
    * typeck2.c (check_narrowing): Adjust OPT_Wnarrowing diagnostics.
    (digest_init_r): Call check_narrowing irrespective of the C++ dialect.
    * decl.c (check_initializer): Likewise.
    * semantics.c (finish_compound_literal): Likewise.

/testsuite
2011-10-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/50841
    Revert:
    2011-10-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/50810
    * g++.dg/cpp0x/warn_cxx0x2.C: New.
    * g++.dg/cpp0x/warn_cxx0x3.C: Likewise.

2011-10-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/50841
    Revert:
    2011-10-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/50810
    * doc/invoke.texi ([-Wnarrowing], [-Wc++0x-compat]): Update.

Modified:
    trunk/gcc/ChangeLog


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug c++/50810] c++0x-compat does not warn about narrowing conversions
  2011-10-20 13:41 [Bug c++/50810] New: c++0x-compat does not warn about narrowing conversions public at alisdairm dot net
                   ` (14 preceding siblings ...)
  2011-10-23 21:16 ` paolo at gcc dot gnu.org
@ 2011-10-23 21:44 ` manu at gcc dot gnu.org
  2011-10-23 21:56 ` manu at gcc dot gnu.org
                   ` (3 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: manu at gcc dot gnu.org @ 2011-10-23 21:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #16 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2011-10-23 21:43:27 UTC ---
(In reply to comment #14)
> Patch needs preliminary clean-ups in gcc/config, etc.

It seems to me that enabling -Wc++0x-compat with -Wall is not a good idea
anyway. I guess many people would not care about upgrading to C++0x for a
while, and they will be pissed off when their builds break. Maybe you should do
it for the release just before -std=c++0x is the default, if such thing is even
planned, but not for 4.7.

(I personally do not understand why this is an obligatory warning in C++0x, it
seems something that many people will consider a nuisance, but that is beyond
the point here).


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug c++/50810] c++0x-compat does not warn about narrowing conversions
  2011-10-20 13:41 [Bug c++/50810] New: c++0x-compat does not warn about narrowing conversions public at alisdairm dot net
                   ` (15 preceding siblings ...)
  2011-10-23 21:44 ` manu at gcc dot gnu.org
@ 2011-10-23 21:56 ` manu at gcc dot gnu.org
  2011-10-24 12:36 ` manu at gcc dot gnu.org
                   ` (2 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: manu at gcc dot gnu.org @ 2011-10-23 21:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #17 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2011-10-23 21:56:21 UTC ---
Now that the patch needs to be recommitted, I would suggest another minor
improvement. Please, remove the %qE so we do not print nonsense!


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug c++/50810] c++0x-compat does not warn about narrowing conversions
  2011-10-20 13:41 [Bug c++/50810] New: c++0x-compat does not warn about narrowing conversions public at alisdairm dot net
                   ` (16 preceding siblings ...)
  2011-10-23 21:56 ` manu at gcc dot gnu.org
@ 2011-10-24 12:36 ` manu at gcc dot gnu.org
  2011-11-02 20:17 ` jason at gcc dot gnu.org
  2011-11-02 20:54 ` jason at gcc dot gnu.org
  19 siblings, 0 replies; 21+ messages in thread
From: manu at gcc dot gnu.org @ 2011-10-24 12:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #18 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2011-10-24 12:35:49 UTC ---
Paolo, I am sorry to say it so bluntly but this solution is nonsense:

http://gcc.gnu.org/ml/gcc-patches/2011-10/msg02160.html

I know it is what Gabriel requested, but it doesn't make sense.

* It doesn't make sense to have a warning conditional of an option when the
negated option cannot disable it. Just don't give it any option then.

* It doesn't make sense that the warning is emitted with option Wnarrowing but
it is disabled by option -Wno-c++0x-compat. This also breaks consistency with
the pragmas and with -Werror=c++0x-compat versus -Werror=narrowing.

* It doesn't make sense to force users to see a warning when they have
requested to not see it using -Wno-narrowing!

Honestly, listen to Jason's stated opinion here:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49793#c2

This PR is only about adding -Wnarrowing to -Wc++0x-compat to get a warning
when not using -std=c++0x. Nothing else. It was fixed by your first patch (plus
not enabling -Wc++0x-compat with -Wall). If you have asked Jason, that patch
would have been pre-approved and committed long ago!


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug c++/50810] c++0x-compat does not warn about narrowing conversions
  2011-10-20 13:41 [Bug c++/50810] New: c++0x-compat does not warn about narrowing conversions public at alisdairm dot net
                   ` (17 preceding siblings ...)
  2011-10-24 12:36 ` manu at gcc dot gnu.org
@ 2011-11-02 20:17 ` jason at gcc dot gnu.org
  2011-11-02 20:54 ` jason at gcc dot gnu.org
  19 siblings, 0 replies; 21+ messages in thread
From: jason at gcc dot gnu.org @ 2011-11-02 20:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #19 from Jason Merrill <jason at gcc dot gnu.org> 2011-11-02 20:16:49 UTC ---
Author: jason
Date: Wed Nov  2 20:16:43 2011
New Revision: 180794

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=180794
Log:
    PR c++/50810
gcc/c-family
    * c-opts.c (c_common_handle_option): Enable -Wnarrowing as part
    of -Wall; include -Wnarrowing in -Wc++0x-compat; adjust default
    Wnarrowing for C++0x and C++98.
    * c.opt ([Wnarrowing]): Update.
gcc/cp
    * typeck2.c (check_narrowing): Adjust OPT_Wnarrowing diagnostics.
    (digest_init_r): Call check_narrowing irrespective of the C++ dialect.
    * decl.c (check_initializer): Likewise.
    * semantics.c (finish_compound_literal): Likewise.
gcc/
    * configure.ac: Add -Wno-narrowing to warning options.
libcpp/
    * configure.ac: Add -Wno-narrowing to warning options.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/warn_cxx0x2.C
    trunk/gcc/testsuite/g++.dg/cpp0x/warn_cxx0x3.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-family/ChangeLog
    trunk/gcc/c-family/c-opts.c
    trunk/gcc/c-family/c.opt
    trunk/gcc/configure
    trunk/gcc/configure.ac
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/semantics.c
    trunk/gcc/cp/typeck2.c
    trunk/gcc/doc/invoke.texi
    trunk/gcc/testsuite/ChangeLog
    trunk/libcpp/ChangeLog
    trunk/libcpp/configure
    trunk/libcpp/configure.ac


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug c++/50810] c++0x-compat does not warn about narrowing conversions
  2011-10-20 13:41 [Bug c++/50810] New: c++0x-compat does not warn about narrowing conversions public at alisdairm dot net
                   ` (18 preceding siblings ...)
  2011-11-02 20:17 ` jason at gcc dot gnu.org
@ 2011-11-02 20:54 ` jason at gcc dot gnu.org
  19 siblings, 0 replies; 21+ messages in thread
From: jason at gcc dot gnu.org @ 2011-11-02 20:54 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #20 from Jason Merrill <jason at gcc dot gnu.org> 2011-11-02 20:54:29 UTC ---
Fixed again.


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2011-11-02 20:54 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-20 13:41 [Bug c++/50810] New: c++0x-compat does not warn about narrowing conversions public at alisdairm dot net
2011-10-20 13:55 ` [Bug c++/50810] " redi at gcc dot gnu.org
2011-10-21 22:50 ` paolo.carlini at oracle dot com
2011-10-21 22:57 ` paolo.carlini at oracle dot com
2011-10-22  1:15 ` manu at gcc dot gnu.org
2011-10-22  1:25 ` manu at gcc dot gnu.org
2011-10-22  4:38 ` jason at gcc dot gnu.org
2011-10-22  9:19 ` paolo.carlini at oracle dot com
2011-10-23  0:37 ` paolo.carlini at oracle dot com
2011-10-23  2:08 ` jason at redhat dot com
2011-10-23  2:13 ` paolo.carlini at oracle dot com
2011-10-23 18:37 ` paolo.carlini at oracle dot com
2011-10-23 18:37 ` paolo at gcc dot gnu.org
2011-10-23 21:02 ` paolo at gcc dot gnu.org
2011-10-23 21:03 ` paolo.carlini at oracle dot com
2011-10-23 21:16 ` paolo at gcc dot gnu.org
2011-10-23 21:44 ` manu at gcc dot gnu.org
2011-10-23 21:56 ` manu at gcc dot gnu.org
2011-10-24 12:36 ` manu at gcc dot gnu.org
2011-11-02 20:17 ` jason at gcc dot gnu.org
2011-11-02 20:54 ` jason at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).