public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99535] New: g++ rejects valid code in constexpr copy ctor and volatile submember
@ 2021-03-11 0:51 Darrell.Wright at gmail dot com
2021-03-11 1:00 ` [Bug c++/99535] " Darrell.Wright at gmail dot com
2021-03-11 13:24 ` redi at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: Darrell.Wright at gmail dot com @ 2021-03-11 0:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99535
Bug ID: 99535
Summary: g++ rejects valid code in constexpr copy ctor and
volatile submember
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: Darrell.Wright at gmail dot com
Target Milestone: ---
The following code produces an error
struct Thing0 {
volatile int a;
constexpr Thing0( int v ): a{v} {}
constexpr Thing0(Thing0 const& other) : a(other.a) {}
constexpr Thing0& operator=(Thing0 const& rhs) {
a = rhs.a;
return *this;
}
~Thing0() = default;
};
Thing0 func0() { return Thing0{5}; }
<source>: In copy constructor 'constexpr Thing0::Thing0(const Thing0&)':
<source>:7:51: error: lvalue-to-rvalue conversion of a volatile lvalue
'other.Thing0::a' with type 'const volatile int'
7 | constexpr Thing0(Thing0 const& other) : a(other.a) {}
| ~~~~~~^
<source>: In member function 'constexpr Thing0& Thing0::operator=(const
Thing0&)':
<source>:9:13: error: lvalue-to-rvalue conversion of a volatile lvalue
'rhs.Thing0::a' with type 'const volatile int'
9 | a = rhs.a;
| ~~~~^
The code should be accepted and is when the special methods are not constexpr.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/99535] g++ rejects valid code in constexpr copy ctor and volatile submember
2021-03-11 0:51 [Bug c++/99535] New: g++ rejects valid code in constexpr copy ctor and volatile submember Darrell.Wright at gmail dot com
@ 2021-03-11 1:00 ` Darrell.Wright at gmail dot com
2021-03-11 13:24 ` redi at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: Darrell.Wright at gmail dot com @ 2021-03-11 1:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99535
--- Comment #1 from Darrell Wright <Darrell.Wright at gmail dot com> ---
I was wrong, http://eel.is/c++draft/expr.const#5.8
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/99535] g++ rejects valid code in constexpr copy ctor and volatile submember
2021-03-11 0:51 [Bug c++/99535] New: g++ rejects valid code in constexpr copy ctor and volatile submember Darrell.Wright at gmail dot com
2021-03-11 1:00 ` [Bug c++/99535] " Darrell.Wright at gmail dot com
@ 2021-03-11 13:24 ` redi at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2021-03-11 13:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99535
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Yes, I think the special member functions are ill-formed (no diagnostic
required) as per http://eel.is/c++draft/dcl.constexpr#6.sentence-1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-11 13:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-11 0:51 [Bug c++/99535] New: g++ rejects valid code in constexpr copy ctor and volatile submember Darrell.Wright at gmail dot com
2021-03-11 1:00 ` [Bug c++/99535] " Darrell.Wright at gmail dot com
2021-03-11 13:24 ` 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).