public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53301] New: Spurious -Wzero-as-null-pointer-constant with reference arguments
@ 2012-05-09 21:14 lloyd at randombit dot net
  2012-05-10  0:41 ` [Bug c++/53301] [4.8 Regression] " paolo.carlini at oracle dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: lloyd at randombit dot net @ 2012-05-09 21:14 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 53301
           Summary: Spurious -Wzero-as-null-pointer-constant with
                    reference arguments
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: lloyd@randombit.net
              Host: x86_64-unknown-linux-gnu
            Target: x86_64-unknown-linux-gnu
             Build: x86_64-unknown-linux-gnu


The following causes a warning under -Wzero-as-null-pointer-constant:

"""
class x { public: x(int v) {} };

void foo(const x& = 0);
"""

wnull.cpp:4:22: warning: zero as null pointer constant
[-Wzero-as-null-pointer-constant]
 void foo(const x& = 0);

The warning is avoided if the argument is passed as a non-reference type or if
the default argument is `x(0)`. Likely the reference type is being treated
identically to a pointer type even though in this case the value is used to
initialize the underlying type, not the reference.

$ g++-4.8.0-r187195 -v
Using built-in specs.
COLLECT_GCC=/usr/local/gcc-4.8.0-r187195/bin/g++-4.8.0-r187195
COLLECT_LTO_WRAPPER=/usr/local/gcc-4.8.0-r187195/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-svn/configure --prefix=/usr/local/gcc-4.8.0-r187195
--enable-languages=c,c++ --program-suffix=-4.8.0-r187195
Thread model: posix
gcc version 4.8.0 20120505 (experimental) (GCC)


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

* [Bug c++/53301] [4.8 Regression] Spurious -Wzero-as-null-pointer-constant with reference arguments
  2012-05-09 21:14 [Bug c++/53301] New: Spurious -Wzero-as-null-pointer-constant with reference arguments lloyd at randombit dot net
@ 2012-05-10  0:41 ` paolo.carlini at oracle dot com
  2012-05-10 21:07 ` paolo at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-10  0:41 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2012-05-09
         AssignedTo|unassigned at gcc dot       |paolo.carlini at oracle dot
                   |gnu.org                     |com
   Target Milestone|---                         |4.7.1
            Summary|Spurious                    |[4.8 Regression] Spurious
                   |-Wzero-as-null-pointer-cons |-Wzero-as-null-pointer-cons
                   |tant with reference         |tant with reference
                   |arguments                   |arguments
     Ever Confirmed|0                           |1

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-09 22:34:00 UTC ---
In a sense this is a regression caused by the fix for PR52718, 4.7.0 doesn't
warn. Tightening the check shouldn't be very difficult.


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

* [Bug c++/53301] [4.8 Regression] Spurious -Wzero-as-null-pointer-constant with reference arguments
  2012-05-09 21:14 [Bug c++/53301] New: Spurious -Wzero-as-null-pointer-constant with reference arguments lloyd at randombit dot net
  2012-05-10  0:41 ` [Bug c++/53301] [4.8 Regression] " paolo.carlini at oracle dot com
@ 2012-05-10 21:07 ` paolo at gcc dot gnu.org
  2012-05-10 21:07 ` paolo at gcc dot gnu.org
  2012-05-10 21:14 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: paolo at gcc dot gnu.org @ 2012-05-10 21:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2012-05-10 21:06:52 UTC ---
Author: paolo
Date: Thu May 10 21:06:42 2012
New Revision: 187378

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=187378
Log:
/cp
2012-05-10  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/53301
    * decl.c (check_default_argument): Fix typo (POINTER_TYPE_P
    instead of TYPE_PTR_P) in zero-as-null-pointer-constant warning.

/testsuite
2012-05-10  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/53301
    * g++.dg/warn/Wzero-as-null-pointer-constant-6.C: New.

Added:
   
branches/gcc-4_7-branch/gcc/testsuite/g++.dg/warn/Wzero-as-null-pointer-constant-6.C
Modified:
    branches/gcc-4_7-branch/gcc/cp/ChangeLog
    branches/gcc-4_7-branch/gcc/cp/decl.c
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog


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

* [Bug c++/53301] [4.8 Regression] Spurious -Wzero-as-null-pointer-constant with reference arguments
  2012-05-09 21:14 [Bug c++/53301] New: Spurious -Wzero-as-null-pointer-constant with reference arguments lloyd at randombit dot net
  2012-05-10  0:41 ` [Bug c++/53301] [4.8 Regression] " paolo.carlini at oracle dot com
  2012-05-10 21:07 ` paolo at gcc dot gnu.org
@ 2012-05-10 21:07 ` paolo at gcc dot gnu.org
  2012-05-10 21:14 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: paolo at gcc dot gnu.org @ 2012-05-10 21:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2012-05-10 21:06:12 UTC ---
Author: paolo
Date: Thu May 10 21:06:05 2012
New Revision: 187377

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=187377
Log:
/cp
2012-05-10  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/53301
    * decl.c (check_default_argument): Fix typo (POINTER_TYPE_P
    instead of TYPE_PTR_P) in zero-as-null-pointer-constant warning.

/testsuite
2012-05-10  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/53301
    * g++.dg/warn/Wzero-as-null-pointer-constant-6.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/warn/Wzero-as-null-pointer-constant-6.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/53301] [4.8 Regression] Spurious -Wzero-as-null-pointer-constant with reference arguments
  2012-05-09 21:14 [Bug c++/53301] New: Spurious -Wzero-as-null-pointer-constant with reference arguments lloyd at randombit dot net
                   ` (2 preceding siblings ...)
  2012-05-10 21:07 ` paolo at gcc dot gnu.org
@ 2012-05-10 21:14 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-10 21:14 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-10 21:08:14 UTC ---
Fixed mainline and 4.7.1.


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

end of thread, other threads:[~2012-05-10 21:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-09 21:14 [Bug c++/53301] New: Spurious -Wzero-as-null-pointer-constant with reference arguments lloyd at randombit dot net
2012-05-10  0:41 ` [Bug c++/53301] [4.8 Regression] " paolo.carlini at oracle dot com
2012-05-10 21:07 ` paolo at gcc dot gnu.org
2012-05-10 21:07 ` paolo at gcc dot gnu.org
2012-05-10 21:14 ` 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).