Consider the code in attachment. clang only properly optimizes the function f()' when it has a definition for the constexpr fieldfoo' in the same compilation unit.
Note that I'm not complaining that I have to provide a definition for field `foo'. But my choice for the compilation unit for this definition should not affect performance?
gcc emits the optimal code for this, EDG rejects because of the 'static constexpr' with "a member of type "Literal" cannot have an in-class initializer".
Extended Description
Consider the code in attachment. clang only properly optimizes the function
f()' when it has a definition for the constexpr field
foo' in the same compilation unit.Note that I'm not complaining that I have to provide a definition for field `foo'. But my choice for the compilation unit for this definition should not affect performance?
$ clang++ -std=c++11 -O2 -Wall -c report.cpp && objdump -d report.o
report.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <_Z1fv>: 0: b8 01 00 00 00 mov $0x1,%eax 5: 83 3d 00 00 00 00 01 cmpl $0x1,0x0(%rip) # c <_Z1fv+0xc> c: 74 05 je 13 <_Z1fv+0x13> e: b8 02 00 00 00 mov $0x2,%eax 13: c3 retq
$ clang++ -DDEF -std=c++11 -O2 -Wall -c report.cpp && objdump -d report.o
report.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <_Z1fv>: 0: b8 01 00 00 00 mov $0x1,%eax 5: c3 retq