public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95701] New: undefined enum conversion accepted in constant expression
@ 2020-06-16 16:51 leni536 at gmail dot com
2020-06-16 17:11 ` [Bug c++/95701] " redi at gcc dot gnu.org
2023-03-06 8:37 ` de34 at live dot cn
0 siblings, 2 replies; 3+ messages in thread
From: leni536 at gmail dot com @ 2020-06-16 16:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95701
Bug ID: 95701
Summary: undefined enum conversion accepted in constant
expression
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: leni536 at gmail dot com
Target Milestone: ---
gcc accepts the following code:
enum E {
one = 1
};
constexpr E foo() {
return static_cast<E>(0xffff);
}
void bar() {
constexpr auto e = foo();
}
Relevant parts of the standard:
https://timsong-cpp.github.io/cppwp/n4659/expr.const#2.6
https://timsong-cpp.github.io/cppwp/n4659/expr.static.cast#10
> The value is unchanged if the original value is within the range of the enumeration values ([dcl.enum]). Otherwise, the behavior is undefined.
https://timsong-cpp.github.io/cppwp/n4659/dcl.enum#8
Following the wording here the "range of the enumeration values" is [0, 1].
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/95701] undefined enum conversion accepted in constant expression
2020-06-16 16:51 [Bug c++/95701] New: undefined enum conversion accepted in constant expression leni536 at gmail dot com
@ 2020-06-16 17:11 ` redi at gcc dot gnu.org
2023-03-06 8:37 ` de34 at live dot cn
1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2020-06-16 17:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95701
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |accepts-invalid
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2020-06-16
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
We still accept it even with -fstrict-enums
Interestingly, so do Clang and EDG.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/95701] undefined enum conversion accepted in constant expression
2020-06-16 16:51 [Bug c++/95701] New: undefined enum conversion accepted in constant expression leni536 at gmail dot com
2020-06-16 17:11 ` [Bug c++/95701] " redi at gcc dot gnu.org
@ 2023-03-06 8:37 ` de34 at live dot cn
1 sibling, 0 replies; 3+ messages in thread
From: de34 at live dot cn @ 2023-03-06 8:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95701
Jiang An <de34 at live dot cn> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |de34 at live dot cn
--- Comment #2 from Jiang An <de34 at live dot cn> ---
This is CWG1766.
https://cplusplus.github.io/CWG/issues/1766.html
Clang implemented the required constant evaluation failures recently, but
seemly decided to keep the behavior outside of constant evaluation unchanged.
https://reviews.llvm.org/D130058
https://reviews.llvm.org/D131307
https://reviews.llvm.org/D131528
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-03-06 8:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-16 16:51 [Bug c++/95701] New: undefined enum conversion accepted in constant expression leni536 at gmail dot com
2020-06-16 17:11 ` [Bug c++/95701] " redi at gcc dot gnu.org
2023-03-06 8:37 ` de34 at live dot cn
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).