Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

invalid codgen for static var in inline function that is constant in some TU but not in others #21976

Open Quuxplusone opened 9 years ago

Quuxplusone commented 9 years ago
Bugzilla Link PR21977
Status NEW
Importance P normal
Reported by Rafael Ávila de Espíndola (rafael@espindo.la)
Reported on 2014-12-19 09:18:01 -0800
Last modified on 2014-12-19 09:22:18 -0800
Version unspecified
Hardware PC Windows NT
CC david.majnemer@gmail.com, dgregor@apple.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk, rnk@google.com
Fixed by commit(s)
Attachments test1a.cpp (158 bytes, text/x-c++src)
test1b.cpp (172 bytes, text/x-c++src)
test2a.cpp (158 bytes, text/x-c++src)
test2b.cpp (205 bytes, text/x-c++src)
Blocks
Blocked by
See also
Both clang and gcc have problems with these tests.

In the first one, if it is compiled as

$CXX -c test1a.cpp -fPIC -O2
$CXX -c test1b.cpp -fPIC
$CXX test1b.o test1a.o -o t1

the resulting program will segfault trying to write to constant memory.

On the second test, if compiled as

$CXX -c test2a.cpp -fPIC -O2
$CXX -c test2b.cpp -fPIC
$CXX test2a.o test2b.o -o t2

it will return the wrong value since the linker will keep the zero initialized
x but the inlined f will think that x is constant and doesn't need
initialization.
Quuxplusone commented 9 years ago

Attached test1a.cpp (158 bytes, text/x-c++src): test1a

Quuxplusone commented 9 years ago

Attached test1b.cpp (172 bytes, text/x-c++src): test1b

Quuxplusone commented 9 years ago

Attached test2a.cpp (158 bytes, text/x-c++src): test2a

Quuxplusone commented 9 years ago

Attached test2b.cpp (205 bytes, text/x-c++src): test2b