[Bug inline-asm/98847] Miscompilation with c++17, templates, and register keyword
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98847 --- Comment #12 from programmerjake at gmail dot com --- (In reply to Jakub Jelinek from comment #11) > Fixed. Thanks!!
[Bug inline-asm/98847] Miscompilation with c++17, templates, and register keyword
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98847 --- Comment #8 from programmerjake at gmail dot com --- Can the fix for this be backported to gcc 8 and 9 too? Thanks!
[Bug inline-asm/98847] Miscompilation with c++17, templates, and register keyword
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98847 --- Comment #4 from programmerjake at gmail dot com --- (In reply to Jakub Jelinek from comment #3) > Created attachment 50066 [details] > gcc11-pr98847.patch > > Untested fix. That will probably also fix bug #98846
[Bug inline-asm/98847] New: Miscompilation with c++17, templates, and register keyword
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98847 Bug ID: 98847 Summary: Miscompilation with c++17, templates, and register keyword Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: inline-asm Assignee: unassigned at gcc dot gnu.org Reporter: programmerjake at gmail dot com Target Milestone: --- Host: x86_64-linux-gnu Target: x86_64-linux-gnu In: https://gcc.godbolt.org/z/49xoKP With the following code: template int template_get_edx() { register int edx asm("edx"); asm("movl $1234, %%edx\n\t# reg=%0" : "=r"(edx)); return edx; } template int template_get_edx(); With: -O -Wall -std=c++17 Miscompiles, allocating %eax to the C++-level edx variable. It's possible the C++ frontend is removing the register keyword before finishing parsing since it also incorrectly warns here (bug #98846) produces: _Z16template_get_edxIvEiv: .LFB1: .file 1 "./example.cpp" .loc 1 2 5 view -0 .cfi_startproc .loc 1 4 5 is_stmt 0 view .LVU1 #APP # 4 "./example.cpp" 1 movl $1234, %edx # reg=%eax # 0 "" 2 .LVL0: .loc 1 6 1 view .LVU2 #NO_APP ret
[Bug c++/98846] New: Spurious -Wregister warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98846 Bug ID: 98846 Summary: Spurious -Wregister warning Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: programmerjake at gmail dot com Target Milestone: --- In: https://gcc.godbolt.org/z/49xoKP With the following code: template int template_get_edx() { register int edx asm("edx"); asm("movl $1234, %%edx\n\t# reg=%0" : "=r"(edx)); return edx; } template int template_get_edx(); With: -O -Wall -std=c++17 produces: : In instantiation of 'int template_get_edx() [with T = void]': :8:37: required from here :3:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 3 | register int edx asm("edx"); I think that warning is spurious because the `register` keyword is required for clang to not ignore the asm("edx").