[Bug c++/80630] New: gcc fails to compile constexpr with -O0/-O1
vsevolod.livinskij at frtk dot ru
gcc-bugzilla@gcc.gnu.org
Thu May 4 18:27:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80630
Bug ID: 80630
Summary: gcc fails to compile constexpr with -O0/-O1
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: vsevolod.livinskij at frtk dot ru
Target Milestone: ---
Created attachment 41318
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41318&action=edit
Reproducer.
gcc fails to compile constexpr at -O0 and -O2 with -std=c++11 and -std=c++14.
Everything works fine with -std=c++17.
Reproducer:
>$ cat repr.cpp
#include <iostream>
#include <utility>
template<typename T>
void foo() {
std::cout << T::debug_typeid << std::endl;
std::make_pair(T::debug_typeid, T::debug_typeid);
}
struct A {
static constexpr uint32_t debug_typeid = 1;
};
int main () {
foo<A>();
}
Error:
>$ g++ -std=c++11 repr.cpp -O0 ; ./a.out
/tmp/cckPqG1z.o: In function `void foo<A>()':
repr.cpp:(.text._Z3fooI1AEvv[_Z3fooI1AEvv]+0x21): undefined reference to
`A::debug_typeid'
repr.cpp:(.text._Z3fooI1AEvv[_Z3fooI1AEvv]+0x26): undefined reference to
`A::debug_typeid'
collect2: error: ld returned 1 exit status
GCC revision:247564
More information about the Gcc-bugs
mailing list