public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95242] New: [10 Regression] spurious "warning: zero as null pointer constant [-Wzero-as-null-pointer-constant]" on comparisons with -std=c++2a
@ 2020-05-20 18:24 gcc at mattwhitlock dot name
  2020-05-22  6:08 ` [Bug c++/95242] [10/11 " rguenth at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: gcc at mattwhitlock dot name @ 2020-05-20 18:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95242

            Bug ID: 95242
           Summary: [10 Regression] spurious "warning: zero as null
                    pointer constant [-Wzero-as-null-pointer-constant]" on
                    comparisons with -std=c++2a
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc at mattwhitlock dot name
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu
            Target: x86_64-pc-linux-gnu
             Build: x86_64-pc-linux-gnu

/* BEGIN bug.cpp */

#include <chrono>
#include <string>

bool bug(std::chrono::milliseconds lhs, std::chrono::milliseconds rhs) {
        return lhs < rhs; // spurious "warning: zero as null pointer constant"
}

bool bug(std::string::const_iterator lhs, std::string::const_iterator rhs) {
        return lhs < rhs; // spurious "warning: zero as null pointer constant"
}

/* END bug.cpp */


$ g++ -std=c++2a -Wzero-as-null-pointer-constant -c bug.cpp
bug.cpp: In function 'bool bug(std::chrono::milliseconds,
std::chrono::milliseconds)':
bug.cpp:5:15: warning: zero as null pointer constant
[-Wzero-as-null-pointer-constant]
    5 |  return lhs < rhs; // spurious "warning: zero as null pointer constant"
      |               ^~~
bug.cpp: In function 'bool
bug(std::__cxx11::basic_string<char>::const_iterator,
std::__cxx11::basic_string<char>::const_iterator)':
bug.cpp:9:15: warning: zero as null pointer constant
[-Wzero-as-null-pointer-constant]
    9 |  return lhs < rhs; // spurious "warning: zero as null pointer constant"
      |               ^~~


$ g++ --version | head -n1
g++ (Gentoo 10.1.0 p1) 10.1.0


The bug is not present in G++ 9.3, and it also is not present in G++ 10.1 in
-std=c++17 (or earlier) mode. This leads me to believe it may be related to the
new three-way comparison operator functionality.

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

end of thread, other threads:[~2020-05-27 14:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-20 18:24 [Bug c++/95242] New: [10 Regression] spurious "warning: zero as null pointer constant [-Wzero-as-null-pointer-constant]" on comparisons with -std=c++2a gcc at mattwhitlock dot name
2020-05-22  6:08 ` [Bug c++/95242] [10/11 " rguenth at gcc dot gnu.org
2020-05-26 21:21 ` jason at gcc dot gnu.org
2020-05-26 23:13 ` redi at gcc dot gnu.org
2020-05-27  5:21 ` daniel.kruegler at googlemail dot com
2020-05-27  6:59 ` redi at gcc dot gnu.org
2020-05-27  8:07 ` daniel.kruegler at googlemail dot com
2020-05-27  8:20 ` redi at gcc dot gnu.org
2020-05-27 14:15 ` 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).