public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99086] New: including <iterator> and defaulting spaceship operator causes compiler segfault
@ 2021-02-13 13:26 crillion at tiscali dot it
2021-02-14 20:50 ` [Bug c++/99086] " redi at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: crillion at tiscali dot it @ 2021-02-13 13:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99086
Bug ID: 99086
Summary: including <iterator> and defaulting spaceship operator
causes compiler segfault
Product: gcc
Version: 10.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: crillion at tiscali dot it
Target Milestone: ---
Created attachment 50178
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50178&action=edit
an archive containing .ii and .s files for windows and linux
Hi,
a little program with a tiny class defaulting the spaceship operator and the
inclusion of <iterator> header causes compiler segfault (the compiler gives
segmentation error while compiling, no executable is produced).
I could see this behaviour on these systems :
(windows 10 64bit)
(it's the g++ 10.2 from mingw-w64 distribution obtained by msys2)
g++ --version
g++ (Rev6, Built by MSYS2 project) 10.2.0
(linux opensuse 15.2 64bit, hosted on virtual box 6.1.16 r140961 (Qt5.6.2),
running on my above windows system)
> g++ --version
g++ (SUSE Linux) 10.2.1 20200825 [revision
c0746a1beb1ba073c7981eb09f55b3d993b32e5c]
==============
program.cpp :
------------------
#include <iterator>
class value_wrapper
{
public :
bool operator<=>(const value_wrapper& rhs) const = default;
private :
unsigned short value_;
};
int main(int, char**)
{
value_wrapper lhs, rhs;
auto x = lhs < rhs;
}
=================================
batch file used to compile it (already including your recommended switches in
bug reporting instructions, which turn out not to mitigate the segfault error)
windows :
g++ -std=c++20 -pedantic -Wall -Wextra -Werror=return-type -Wshadow=local
-Wempty-body -fdiagnostics-color -s -Os -fno-strict-aliasing -fwrapv
-fno-aggressive-loop-optimizations program.cpp -save-temps -o program_gpp.exe
linux :
g++ -std=c++20 -pedantic -Wall -Wextra -Werror=return-type -Wshadow=local
-Wempty-body -fdiagnostics-color -s -Os -fno-strict-aliasing -fwrapv
-fno-aggressive-loop-optimizations program.cpp -save-temps -o program_gpp
I add as attachment a 7zip archive containing the requested .ii and .s files
respectively for the windows and linux compilation:
program.ii.linux
program.ii.windows
program.s.linux
program.s.windows
I was originally using a field of type boost gregorian date, which in turn
causes inclusion of <iterator>. I could reduce boost include files just to the
inclusion of <iterator>
Sorry but I didn't reduce, nor inspect the <iterator> header, since I consider
standard library headers too complicated for me to analyze.
Thanks,
Marco
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/99086] including <iterator> and defaulting spaceship operator causes compiler segfault
2021-02-13 13:26 [Bug c++/99086] New: including <iterator> and defaulting spaceship operator causes compiler segfault crillion at tiscali dot it
@ 2021-02-14 20:50 ` redi at gcc dot gnu.org
2021-02-14 20:55 ` redi at gcc dot gnu.org
2021-04-13 17:13 ` redi at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2021-02-14 20:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99086
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Keywords| |ice-on-invalid-code
Known to work| |11.0
Known to fail| |10.2.1
Last reconfirmed| |2021-02-14
CC| |jason at gcc dot gnu.org
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to crillion from comment #0)
> #include <iterator>
>
> class value_wrapper
> {
> public :
>
> bool operator<=>(const value_wrapper& rhs) const = default;
This is a bug, the spaceship operator has to return one of
std::strong_ordering, std::weak_ordering or std::partial_ordering.
GCC's crash on the invalid code has already been fixed in r11-5866:
c++: Fix defaulted <=> fallback to < and == [PR96299]
I don't know if there are plans to backport that.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/99086] including <iterator> and defaulting spaceship operator causes compiler segfault
2021-02-13 13:26 [Bug c++/99086] New: including <iterator> and defaulting spaceship operator causes compiler segfault crillion at tiscali dot it
2021-02-14 20:50 ` [Bug c++/99086] " redi at gcc dot gnu.org
@ 2021-02-14 20:55 ` redi at gcc dot gnu.org
2021-04-13 17:13 ` redi at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2021-02-14 20:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99086
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #1)
> (In reply to crillion from comment #0)
> > #include <iterator>
> >
> > class value_wrapper
> > {
> > public :
> >
> > bool operator<=>(const value_wrapper& rhs) const = default;
>
> This is a bug, the spaceship operator has to return one of
> std::strong_ordering, std::weak_ordering or std::partial_ordering.
That's not quite true, it can be something that std::strong_ordering is
convertible to. But it can't be bool.
If you're defaulting it, you probably want to just return auto and let the
compiler get the type right.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/99086] including <iterator> and defaulting spaceship operator causes compiler segfault
2021-02-13 13:26 [Bug c++/99086] New: including <iterator> and defaulting spaceship operator causes compiler segfault crillion at tiscali dot it
2021-02-14 20:50 ` [Bug c++/99086] " redi at gcc dot gnu.org
2021-02-14 20:55 ` redi at gcc dot gnu.org
@ 2021-04-13 17:13 ` redi at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2021-04-13 17:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99086
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #1)
> GCC's crash on the invalid code has already been fixed in r11-5866:
>
> c++: Fix defaulted <=> fallback to < and == [PR96299]
And we already have multiple duplicates of this.
*** This bug has been marked as a duplicate of bug 97121 ***
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-04-13 17:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-13 13:26 [Bug c++/99086] New: including <iterator> and defaulting spaceship operator causes compiler segfault crillion at tiscali dot it
2021-02-14 20:50 ` [Bug c++/99086] " redi at gcc dot gnu.org
2021-02-14 20:55 ` redi at gcc dot gnu.org
2021-04-13 17:13 ` redi 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).