public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/44277] [C++0x] Add warning to facilitate nullptr conversion.
       [not found] <bug-44277-4@http.gcc.gnu.org/bugzilla/>
@ 2011-10-17 18:13 ` paolo.carlini at oracle dot com
  2011-10-17 18:53 ` jason at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-17 18:13 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-17 18:12:49 UTC ---
Jason, what do you think about this?


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

* [Bug c++/44277] [C++0x] Add warning to facilitate nullptr conversion.
       [not found] <bug-44277-4@http.gcc.gnu.org/bugzilla/>
  2011-10-17 18:13 ` [Bug c++/44277] [C++0x] Add warning to facilitate nullptr conversion paolo.carlini at oracle dot com
@ 2011-10-17 18:53 ` jason at gcc dot gnu.org
  2011-10-17 18:55 ` paolo.carlini at oracle dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2011-10-17 18:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> 2011-10-17 18:53:07 UTC ---
That seems reasonable, though I wouldn't have it enabled by default or -Wall. 
Could start with replacing convert_and_check with a cp_convert_and_check that
also performs this check.


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

* [Bug c++/44277] [C++0x] Add warning to facilitate nullptr conversion.
       [not found] <bug-44277-4@http.gcc.gnu.org/bugzilla/>
  2011-10-17 18:13 ` [Bug c++/44277] [C++0x] Add warning to facilitate nullptr conversion paolo.carlini at oracle dot com
  2011-10-17 18:53 ` jason at gcc dot gnu.org
@ 2011-10-17 18:55 ` paolo.carlini at oracle dot com
  2011-10-17 18:56 ` paolo.carlini at oracle dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-17 18:55 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED


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

* [Bug c++/44277] [C++0x] Add warning to facilitate nullptr conversion.
       [not found] <bug-44277-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2011-10-17 18:55 ` paolo.carlini at oracle dot com
@ 2011-10-17 18:56 ` paolo.carlini at oracle dot com
  2011-10-17 23:13 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-17 18:56 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011-10-17
         AssignedTo|unassigned at gcc dot       |paolo.carlini at oracle dot
                   |gnu.org                     |com
     Ever Confirmed|0                           |1

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-17 18:55:05 UTC ---
Thanks a lot for the tip.


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

* [Bug c++/44277] [C++0x] Add warning to facilitate nullptr conversion.
       [not found] <bug-44277-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2011-10-17 18:56 ` paolo.carlini at oracle dot com
@ 2011-10-17 23:13 ` paolo.carlini at oracle dot com
  2011-10-17 23:29 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-17 23:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-17 23:12:58 UTC ---
Jason, would it make sense to produce the warning in cp_convert_to_pointer? I
see the function does *not* have a complain argument (which would be used in
the existing error calls), and that is good because it means we should be safe
wrt undesired warnings in sfinae. Then, about the below, I guess we have also
to decide what to do wrt pointers to members: the same? Then, we'll have also
to decide the exact *name* of the  warning... So many questions ;)

////////////

--- cvt.c       (revision 180110)
+++ cvt.c       (working copy)
@@ -209,7 +209,11 @@ cp_convert_to_pointer (tree type, tree expr)
          expr = build_int_cst_type (type, -1);
        }
       else
-       expr = build_int_cst (type, 0);
+       {
+         if (!NULLPTR_TYPE_P (TREE_TYPE (expr)))
+           warning (0, "zero as null pointer constant");
+         expr = build_int_cst (type, 0);
+       }

       return expr;
     }


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

* [Bug c++/44277] [C++0x] Add warning to facilitate nullptr conversion.
       [not found] <bug-44277-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2011-10-17 23:13 ` paolo.carlini at oracle dot com
@ 2011-10-17 23:29 ` paolo.carlini at oracle dot com
  2011-11-01 23:28 ` paolo at gcc dot gnu.org
  2011-11-01 23:30 ` paolo.carlini at oracle dot com
  7 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-17 23:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-17 23:29:00 UTC ---
Humm, I already see something wrong in my wild idea: the patchlet triggers also
in conditionals, eg 'if (!p)'...


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

* [Bug c++/44277] [C++0x] Add warning to facilitate nullptr conversion.
       [not found] <bug-44277-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2011-10-17 23:29 ` paolo.carlini at oracle dot com
@ 2011-11-01 23:28 ` paolo at gcc dot gnu.org
  2011-11-01 23:30 ` paolo.carlini at oracle dot com
  7 siblings, 0 replies; 8+ messages in thread
From: paolo at gcc dot gnu.org @ 2011-11-01 23:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2011-11-01 23:28:23 UTC ---
Author: paolo
Date: Tue Nov  1 23:28:19 2011
New Revision: 180750

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=180750
Log:
/cp
2011-11-01  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/44277
    * cvt.c (cp_convert_to_pointer): Warn for zero as null pointer
    constant.
    * typeck.c (cp_truthvalue_conversion): Handle pointers and member
    function pointers under c_inhibit_evaluation_warnings; use
    nullptr_node for data member pointers.
    (cp_build_binary_op): Tweak, just forward to cp_convert op1,
    either a nullptr_node or an integer_zero_node.
    (build_ptrmemfunc): Use nullptr_node.
    * init.c (build_zero_init_1): Likewise.

/c-family
2011-11-01  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/44277
    * c.opt: Add Wzero-as-null-pointer-constant.

/gcc
2011-11-01  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/44277
    * doc/invoke.texi: Document -Wzero-as-null-pointer-constant.

/testsuite
2011-11-01  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/44277
    * g++.dg/warn/Wzero-as-null-pointer-constant-1.C: New.
    * g++.dg/cpp0x/Wzero-as-null-pointer-constant-1.C: Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/Wzero-as-null-pointer-constant-1.C
    trunk/gcc/testsuite/g++.dg/warn/Wzero-as-null-pointer-constant-1.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-family/ChangeLog
    trunk/gcc/c-family/c.opt
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cvt.c
    trunk/gcc/cp/init.c
    trunk/gcc/cp/typeck.c
    trunk/gcc/doc/invoke.texi
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/44277] [C++0x] Add warning to facilitate nullptr conversion.
       [not found] <bug-44277-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2011-11-01 23:28 ` paolo at gcc dot gnu.org
@ 2011-11-01 23:30 ` paolo.carlini at oracle dot com
  7 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-11-01 23:30 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-11-01 23:30:08 UTC ---
Done for 4.7.0.


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

end of thread, other threads:[~2011-11-01 23:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-44277-4@http.gcc.gnu.org/bugzilla/>
2011-10-17 18:13 ` [Bug c++/44277] [C++0x] Add warning to facilitate nullptr conversion paolo.carlini at oracle dot com
2011-10-17 18:53 ` jason at gcc dot gnu.org
2011-10-17 18:55 ` paolo.carlini at oracle dot com
2011-10-17 18:56 ` paolo.carlini at oracle dot com
2011-10-17 23:13 ` paolo.carlini at oracle dot com
2011-10-17 23:29 ` paolo.carlini at oracle dot com
2011-11-01 23:28 ` paolo at gcc dot gnu.org
2011-11-01 23:30 ` paolo.carlini at oracle dot com

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).