public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100800] New: ternary operator doesn't accept T with conversion operator and nullptr
@ 2021-05-27 11:45 sbence92 at gmail dot com
2021-08-12 5:21 ` [Bug c++/100800] " pinskia at gcc dot gnu.org
2021-12-20 17:31 ` pinskia at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: sbence92 at gmail dot com @ 2021-05-27 11:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100800
Bug ID: 100800
Summary: ternary operator doesn't accept T with conversion
operator and nullptr
Product: gcc
Version: 11.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: sbence92 at gmail dot com
Target Milestone: ---
Host: x86_64-w64-mingw32, x86_64-linux-gnu
Target: x86_64-w64-mingw32, x86_64-linux-gnu
Build: x86_64-w64-mingw32, x86_64-linux-gnu
The following code fails to compile with the following message:
error: operands to '?:' have different types 'S2' and 'std::nullptr_t'
Even though S2 is convertible to S* and nullptr is convertible to S* so they
have a common type to convert to. Also the standard mentions that pointer
conversion rules are applied to bring the second and third operand to a common
type, so this code seems to be valid.
FYI clang and icc accepts this, msvc and gcc doesn't.
struct S{};
struct S2 {
operator S*();
};
S* f() { return true ? S2{} : nullptr; }
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/100800] ternary operator doesn't accept T with conversion operator and nullptr
2021-05-27 11:45 [Bug c++/100800] New: ternary operator doesn't accept T with conversion operator and nullptr sbence92 at gmail dot com
@ 2021-08-12 5:21 ` pinskia at gcc dot gnu.org
2021-12-20 17:31 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-12 5:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100800
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2021-08-12
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/100800] ternary operator doesn't accept T with conversion operator and nullptr
2021-05-27 11:45 [Bug c++/100800] New: ternary operator doesn't accept T with conversion operator and nullptr sbence92 at gmail dot com
2021-08-12 5:21 ` [Bug c++/100800] " pinskia at gcc dot gnu.org
@ 2021-12-20 17:31 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-20 17:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100800
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 94039.
*** This bug has been marked as a duplicate of bug 94039 ***
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-12-20 17:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-27 11:45 [Bug c++/100800] New: ternary operator doesn't accept T with conversion operator and nullptr sbence92 at gmail dot com
2021-08-12 5:21 ` [Bug c++/100800] " pinskia at gcc dot gnu.org
2021-12-20 17:31 ` pinskia 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).