https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87145
Bug ID: 87145 Summary: Implicit conversion to scoped enum fails: "error: taking address of temporary/rvalue" Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: programmer at posteo dot de Target Milestone: --- The following code can be compiled with GCC 6.3, but GCC 7.1 and later abort the compilation with an error message. ===== #include <cstddef> #include <type_traits> enum class Enum : std::size_t {}; struct Pod { std::size_t val; constexpr operator Enum() const { return static_cast<Enum>(val); } }; template<std::size_t N> constexpr void foo() { using Foo = std::integral_constant<Enum, Pod{N}>; } int main() { foo<2>(); } ===== Error message from current trunk: ===== <source>: In instantiation of 'constexpr void foo() [with long unsigned int N = 2]': <source>:21:10: required from here <source>:17:50: error: taking address of rvalue [-fpermissive] 17 | using Foo = std::integral_constant<Enum, Pod{N}>; | ^ <source>:17:50: error: no matching function for call to 'Pod::operator Enum(Pod*)' <source>:10:13: note: candidate: 'constexpr Pod::operator Enum() const' 10 | constexpr operator Enum() const { | ^~~~~~~~ <source>:10:13: note: candidate expects 0 arguments, 1 provided Compiler returned: 1 ===== Live demo: https://godbolt.org/z/vfvGiS PS: Which version should I choose if multiple versions are affected: stable, trunk or [the first version with that regression]?