public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106357] New: [12/13 Regression] direct-list-initialization of enum class from a variable of another enum class type fails
@ 2022-07-19 16:00 enolan at alumni dot cmu.edu
2022-07-19 16:07 ` [Bug c++/106357] " pinskia at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: enolan at alumni dot cmu.edu @ 2022-07-19 16:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106357
Bug ID: 106357
Summary: [12/13 Regression] direct-list-initialization of enum
class from a variable of another enum class type fails
Product: gcc
Version: 12.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: enolan at alumni dot cmu.edu
Target Milestone: ---
This example fails with GCC 12:
enum class A {
a
};
enum class B {
b
};
int main() {
A a{};
B b{a};
}
---
P0138 added this language to the standard for C++17 (see:
https://eel.is/c++draft/dcl.init.list#3.8)
> if T is an enumeration with a fixed underlying type ([dcl.enum]) U, the
> initializer-list has a single element v, v can be implicitly converted to U,
> and the initialization is direct-list-initialization, the object is
> initialized with the value T(v) ([expr.type.conv]);
The above test case works in GCC 7-11 but appears to have regressed in GCC 12
and on trunk.
---
> the exact version of GCC
gcc version 12.1.1 20220507 (Red Hat 12.1.1-1) (GCC)
> the system type
Fedora release 37 (Rawhide)
> the options given when GCC was configured/built
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,lto --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-gcc-major-version-only --enable-libstdcxx-backtrace
--with-linker-hash-style=gnu --enable-plugin --enable-initfini-array
--with-isl=/builddir/build/BUILD/gcc-12.1.1-20220507/obj-x86_64-redhat-linux/isl-install
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-offload-defaulted --enable-gnu-indirect-function --enable-cet
--with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
--with-build-config=bootstrap-lto --enable-link-serialization=1
> the complete command line that triggers the bug
g++ -std=c++17 poc2.cpp
> the compiler output (error messages, warnings, etc.)
poc2.cpp: In function ‘int main()’:
poc2.cpp:10:9: error: cannot convert ‘A’ to ‘B’ in initialization
10 | B b{a};
| ^
| |
| A
> the preprocessed file (*.i*) that triggers the bug, generated by adding -save-temps to the complete compilation command, or, in the case of a bug report for the GNAT frontend, a complete set of source files (see below).
# 0 "poc2.cpp"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 0 "<command-line>" 2
# 1 "poc2.cpp"
enum class A {
a
};
enum class B {
b
};
int main() {
A a{};
B b{a};
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/106357] [12/13 Regression] direct-list-initialization of enum class from a variable of another enum class type fails
2022-07-19 16:00 [Bug c++/106357] New: [12/13 Regression] direct-list-initialization of enum class from a variable of another enum class type fails enolan at alumni dot cmu.edu
@ 2022-07-19 16:07 ` pinskia at gcc dot gnu.org
2022-07-19 16:10 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-07-19 16:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106357
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I think the testcase is invalid as the enum does not have "fixed underlying
type"
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/106357] [12/13 Regression] direct-list-initialization of enum class from a variable of another enum class type fails
2022-07-19 16:00 [Bug c++/106357] New: [12/13 Regression] direct-list-initialization of enum class from a variable of another enum class type fails enolan at alumni dot cmu.edu
2022-07-19 16:07 ` [Bug c++/106357] " pinskia at gcc dot gnu.org
@ 2022-07-19 16:10 ` pinskia at gcc dot gnu.org
2022-07-19 16:55 ` redi at gcc dot gnu.org
2022-07-19 16:58 ` redi at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-07-19 16:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106357
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
scoped enums also cannot be implicitly converted to another type.
So GCC is correct.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/106357] [12/13 Regression] direct-list-initialization of enum class from a variable of another enum class type fails
2022-07-19 16:00 [Bug c++/106357] New: [12/13 Regression] direct-list-initialization of enum class from a variable of another enum class type fails enolan at alumni dot cmu.edu
2022-07-19 16:07 ` [Bug c++/106357] " pinskia at gcc dot gnu.org
2022-07-19 16:10 ` pinskia at gcc dot gnu.org
@ 2022-07-19 16:55 ` redi at gcc dot gnu.org
2022-07-19 16:58 ` redi at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2022-07-19 16:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106357
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> I think the testcase is invalid as the enum does not have "fixed underlying
> type"
Scoped enums always have a fixed underlying type.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/106357] [12/13 Regression] direct-list-initialization of enum class from a variable of another enum class type fails
2022-07-19 16:00 [Bug c++/106357] New: [12/13 Regression] direct-list-initialization of enum class from a variable of another enum class type fails enolan at alumni dot cmu.edu
` (2 preceding siblings ...)
2022-07-19 16:55 ` redi at gcc dot gnu.org
@ 2022-07-19 16:58 ` redi at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2022-07-19 16:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106357
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This changed intentionally with r12-85-g5f8aed72e76970
c++: Refine enum direct-list-initialization [CWG2374]
This implements the wording changes of CWG2374, which clarifies the
wording of P0138 to forbid e.g. direct-list-initialization of a scoped
enumeration from a different scoped enumeration.
This was a change in the standard: https://wg21.link/cwg2374
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-07-19 16:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-19 16:00 [Bug c++/106357] New: [12/13 Regression] direct-list-initialization of enum class from a variable of another enum class type fails enolan at alumni dot cmu.edu
2022-07-19 16:07 ` [Bug c++/106357] " pinskia at gcc dot gnu.org
2022-07-19 16:10 ` pinskia at gcc dot gnu.org
2022-07-19 16:55 ` redi at gcc dot gnu.org
2022-07-19 16:58 ` 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).