[Bug c++/80264] New: g++ ignores register assignments in template functions
blubban at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Mar 30 14:39:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80264
Bug ID: 80264
Summary: g++ ignores register assignments in template functions
Product: gcc
Version: 7.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: blubban at gmail dot com
Target Milestone: ---
Created attachment 41092
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41092&action=edit
Testcase
Input (also attached):
template<int x>
void foo1()
{
register int bar asm("NOT-A-REGISTER");
}
template void foo1<0>();
template<int x>
void foo2()
{
register int edi asm("edi") = 42;
asm volatile("" :: "r"(edi));
}
template void foo2<0>();
void foo3()
{
register int edi asm("edi") = 42;
asm volatile("" :: "r"(edi));
}
Command line:
g++ -S template-inline-asm.cpp -o-
(the flags don't affect this issue)
Expected output:
First function: error: invalid register name for 'bar'
Second: movl $42, %edi (or equivalent)
Third: movl $42, %edi
Actual output:
First one: Compiler silently emits a blank function (other than an unused
variable warning)
Second: movl $42, %ebx (%eax on -O1 or higher)
Third: As expected
Tested versions:
g++ 7.0.1 20170330 x86_64-linux-gnu (Godbolt)
g++ 6.2.0-5ubuntu12 x86_64-linux-gnu (Lubuntu 16.10)
g++ 4.4.7-1ubuntu2 x86_64-linux-gnu (Godbolt)
clang++ 3.8.1-12ubuntu1 (acts as expected)
7.0.1 config:
Using built-in specs.
COLLECT_GCC=/opt/compiler-explorer/gcc-7-snapshot/bin/g++
Target: x86_64-linux-gnu
Configured with: ../gcc-trunk-20170330/configure --prefix /root/staging
--build=x86_64-linux-gnu --disable-multilibs --disable-bootstrap
--enable-clocale=gnu --enable-languages=c,c++ --enable-ld=yes --enable-gold=yes
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-linker-build-id
--enable-lto --enable-plugins --enable-threads=posix --host=x86_64-linux-gnu
--target=x86_64-linux-gnu --with-pkgversion=GCC-Explorer-Build
Thread model: posix
gcc version 7.0.1 20170330 (experimental) (GCC-Explorer-Build)
COLLECT_GCC_OPTIONS='-g' '-o'
'/tmp/compiler-explorer-compiler117230-57-19womo8.vtf1hmpldi/output.s'
'-masm=intel' '-S' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
/opt/compiler-explorer/gcc-trunk-20170330/bin/../libexec/gcc/x86_64-linux-gnu/7.0.1/cc1plus
-quiet -v -imultiarch x86_64-linux-gnu -iprefix
/opt/compiler-explorer/gcc-trunk-20170330/bin/../lib/gcc/x86_64-linux-gnu/7.0.1/
-D_GNU_SOURCE <source> -quiet -dumpbase example.cpp -masm=intel -mtune=generic
-march=x86-64 -auxbase-strip
/tmp/compiler-explorer-compiler117230-57-19womo8.vtf1hmpldi/output.s -g
-version -o
/tmp/compiler-explorer-compiler117230-57-19womo8.vtf1hmpldi/output.s
GNU C++14 (GCC-Explorer-Build) version 7.0.1 20170330 (experimental)
(x86_64-linux-gnu)
compiled by GNU C version 5.4.0 20160609, GMP version 6.1.0, MPFR
version 3.1.4, MPC version 1.0.3, isl version isl-0.16.1-GMP
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
More information about the Gcc-bugs
mailing list