public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/33661] template methods forget explicit local reg vars [not found] <bug-33661-4@http.gcc.gnu.org/bugzilla/> @ 2011-08-24 10:09 ` s.schuh85 at gmail dot com 2012-05-31 8:19 ` Aleksandrs.Saveljevs at gmail dot com ` (10 subsequent siblings) 11 siblings, 0 replies; 12+ messages in thread From: s.schuh85 at gmail dot com @ 2011-08-24 10:09 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33661 Stefan Schuh <s.schuh85 at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |s.schuh85 at gmail dot com --- Comment #9 from Stefan Schuh <s.schuh85 at gmail dot com> 2011-08-24 10:00:48 UTC --- I can confirm this bug in gcc version 4.5.2 on i686-linux-gnu and in gcc version 4.6.0 on s390x-ibm-linux-gnu ^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/33661] template methods forget explicit local reg vars [not found] <bug-33661-4@http.gcc.gnu.org/bugzilla/> 2011-08-24 10:09 ` [Bug c++/33661] template methods forget explicit local reg vars s.schuh85 at gmail dot com @ 2012-05-31 8:19 ` Aleksandrs.Saveljevs at gmail dot com 2014-10-26 14:25 ` adam at os dot inf.tu-dresden.de ` (9 subsequent siblings) 11 siblings, 0 replies; 12+ messages in thread From: Aleksandrs.Saveljevs at gmail dot com @ 2012-05-31 8:19 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33661 --- Comment #10 from Aleksandrs Saveljevs <Aleksandrs.Saveljevs at gmail dot com> 2012-05-31 08:16:41 UTC --- Confirming that the bug still exists on ARM, x86 and x86_64 as of GCC 4.6.3. ^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/33661] template methods forget explicit local reg vars [not found] <bug-33661-4@http.gcc.gnu.org/bugzilla/> 2011-08-24 10:09 ` [Bug c++/33661] template methods forget explicit local reg vars s.schuh85 at gmail dot com 2012-05-31 8:19 ` Aleksandrs.Saveljevs at gmail dot com @ 2014-10-26 14:25 ` adam at os dot inf.tu-dresden.de 2015-06-03 10:05 ` pinskia at gcc dot gnu.org ` (8 subsequent siblings) 11 siblings, 0 replies; 12+ messages in thread From: adam at os dot inf.tu-dresden.de @ 2014-10-26 14:25 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33661 --- Comment #11 from Adam Lackorzynski <adam at os dot inf.tu-dresden.de> --- Confirming issue still exists for 4.7.4, 4.8.4, 4.9.2 and 5.0 (tested on x86_64). ^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/33661] template methods forget explicit local reg vars [not found] <bug-33661-4@http.gcc.gnu.org/bugzilla/> ` (2 preceding siblings ...) 2014-10-26 14:25 ` adam at os dot inf.tu-dresden.de @ 2015-06-03 10:05 ` pinskia at gcc dot gnu.org 2020-04-11 6:13 ` [Bug c++/33661] template methods forget explicit local register asm vars mp8191mp at gmail dot com ` (7 subsequent siblings) 11 siblings, 0 replies; 12+ messages in thread From: pinskia at gcc dot gnu.org @ 2015-06-03 10:05 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33661 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |krebbel at gcc dot gnu.org --- Comment #12 from Andrew Pinski <pinskia at gcc dot gnu.org> --- *** Bug 66393 has been marked as a duplicate of this bug. *** ^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/33661] template methods forget explicit local register asm vars [not found] <bug-33661-4@http.gcc.gnu.org/bugzilla/> ` (3 preceding siblings ...) 2015-06-03 10:05 ` pinskia at gcc dot gnu.org @ 2020-04-11 6:13 ` mp8191mp at gmail dot com 2021-01-28 15:14 ` cvs-commit at gcc dot gnu.org ` (6 subsequent siblings) 11 siblings, 0 replies; 12+ messages in thread From: mp8191mp at gmail dot com @ 2020-04-11 6:13 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33661 Martin Papik <mp8191mp at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mp8191mp at gmail dot com --- Comment #17 from Martin Papik <mp8191mp at gmail dot com> --- Hello, I found a bug, which I think is a duplicate of this one, but am not 100% sure. Below is a minimal piece of code which triggers the bug. All versions of gcc seem to be affected, as seen on compiler explorer, https://godbolt.org/z/jFMj8b, which also shows a difference in gimple, the templated version is missing the explicit naming attributes. Is this the same bug? If so, is there some technical reason why a clear miscompilation persists for as long as it seems to? What I mean is this, if a bug like this persists for this long, it could be taken to mean that the bug is too big for a casual volunteer. Would that be the case? Can someone familiar with the code base tell me what I'd need to know to fix this, e.g. what's wrong with the patch, is it better to fix the patch or start from scratch. $ cat bug.cpp #define DEMONSTRABLY_IDENTICAL \ long ret; \ register long r10 __asm__("r10") = (long)a4; \ __asm__ __volatile__ ("syscall" \ : "=a"(ret) \ : "a"(n), "D"(a1), "S"(a2), "d"(a3), "r"(r10) \ : "rcx", "r11", "memory" \ ); enum class sysnr : long { // accept4 has enough parameters to require extra registers and trigger the bug accept4 = 0x120 }; static __inline long sys_01(long n, long a1, long a2, long a3, long a4) { DEMONSTRABLY_IDENTICAL return ret; } template <sysnr SYS_NR, typename RET, typename T1, typename T2, typename T3, typename T4> RET sys_02(T1 a1, T2 a2, T3 a3, T4 a4) { constexpr long n = (long) SYS_NR; DEMONSTRABLY_IDENTICAL return (RET)ret; } void test_01 () { sys_01( (long)sysnr::accept4, 0xfeed01, 0xfeed02, 0xfeed03, 0xfeed04 ); } void test_02() { sys_02<sysnr::accept4, long>( 0xfeed01, 0xfeed02, 0xfeed03, 0xfeed04 ); } void test_03() { sys_02<sysnr::accept4, long, long, long, long, long>( 0xfeed01, 0xfeed02, 0xfeed03, 0xfeed04 ); } $ g++ -std=c++11 -O1 bug.cpp -c -o bug.c $ objdump -Cd bug.o bug.o: file format elf64-x86-64 Disassembly of section .text: 0000000000000000 <test_01()>: 0: 41 ba 04 ed fe 00 mov $0xfeed04,%r10d 6: b8 20 01 00 00 mov $0x120,%eax b: bf 01 ed fe 00 mov $0xfeed01,%edi 10: be 02 ed fe 00 mov $0xfeed02,%esi 15: ba 03 ed fe 00 mov $0xfeed03,%edx 1a: 0f 05 syscall 1c: c3 retq 000000000000001d <test_02()>: 1d: b8 20 01 00 00 mov $0x120,%eax 22: bf 01 ed fe 00 mov $0xfeed01,%edi 27: be 02 ed fe 00 mov $0xfeed02,%esi 2c: ba 03 ed fe 00 mov $0xfeed03,%edx 31: 41 b8 04 ed fe 00 mov $0xfeed04,%r8d 37: 0f 05 syscall 39: c3 retq 000000000000003a <test_03()>: 3a: b8 20 01 00 00 mov $0x120,%eax 3f: bf 01 ed fe 00 mov $0xfeed01,%edi 44: be 02 ed fe 00 mov $0xfeed02,%esi 49: ba 03 ed fe 00 mov $0xfeed03,%edx 4e: 41 b8 04 ed fe 00 mov $0xfeed04,%r8d 54: 0f 05 syscall 56: c3 retq ^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/33661] template methods forget explicit local register asm vars [not found] <bug-33661-4@http.gcc.gnu.org/bugzilla/> ` (4 preceding siblings ...) 2020-04-11 6:13 ` [Bug c++/33661] template methods forget explicit local register asm vars mp8191mp at gmail dot com @ 2021-01-28 15:14 ` cvs-commit at gcc dot gnu.org 2021-01-29 19:20 ` cvs-commit at gcc dot gnu.org ` (5 subsequent siblings) 11 siblings, 0 replies; 12+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2021-01-28 15:14 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33661 --- Comment #18 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:6bb207b468da36d9d99c63409dc4098514759c90 commit r11-6958-g6bb207b468da36d9d99c63409dc4098514759c90 Author: Jakub Jelinek <jakub@redhat.com> Date: Thu Jan 28 16:13:11 2021 +0100 c++: Fix up handling of register ... asm ("...") vars in templates [PR33661, PR98847] As the testcase shows, for vars appearing in templates, we don't attach the asm spec string to the pattern decls, nor pass it back to cp_finish_decl during instantiation. The following patch does that. 2021-01-28 Jakub Jelinek <jakub@redhat.com> PR c++/33661 PR c++/98847 * decl.c (cp_finish_decl): For register vars with asmspec in templates call set_user_assembler_name and set DECL_HARD_REGISTER. * pt.c (tsubst_expr): When instantiating DECL_HARD_REGISTER vars, pass asmspec_tree to cp_finish_decl. * g++.target/i386/pr98847.C: New test. ^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/33661] template methods forget explicit local register asm vars [not found] <bug-33661-4@http.gcc.gnu.org/bugzilla/> ` (5 preceding siblings ...) 2021-01-28 15:14 ` cvs-commit at gcc dot gnu.org @ 2021-01-29 19:20 ` cvs-commit at gcc dot gnu.org 2021-01-30 12:40 ` fw at gcc dot gnu.org ` (4 subsequent siblings) 11 siblings, 0 replies; 12+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2021-01-29 19:20 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33661 --- Comment #19 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-10 branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:cf93f94b3498f3925895fb0bbfd4b64232b9987a commit r10-9323-gcf93f94b3498f3925895fb0bbfd4b64232b9987a Author: Jakub Jelinek <jakub@redhat.com> Date: Thu Jan 28 16:13:11 2021 +0100 c++: Fix up handling of register ... asm ("...") vars in templates [PR33661, PR98847] As the testcase shows, for vars appearing in templates, we don't attach the asm spec string to the pattern decls, nor pass it back to cp_finish_decl during instantiation. The following patch does that. 2021-01-28 Jakub Jelinek <jakub@redhat.com> PR c++/33661 PR c++/98847 * decl.c (cp_finish_decl): For register vars with asmspec in templates call set_user_assembler_name and set DECL_HARD_REGISTER. * pt.c (tsubst_expr): When instantiating DECL_HARD_REGISTER vars, pass asmspec_tree to cp_finish_decl. * g++.target/i386/pr98847.C: New test. ^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/33661] template methods forget explicit local register asm vars [not found] <bug-33661-4@http.gcc.gnu.org/bugzilla/> ` (6 preceding siblings ...) 2021-01-29 19:20 ` cvs-commit at gcc dot gnu.org @ 2021-01-30 12:40 ` fw at gcc dot gnu.org 2021-04-20 23:31 ` cvs-commit at gcc dot gnu.org ` (3 subsequent siblings) 11 siblings, 0 replies; 12+ messages in thread From: fw at gcc dot gnu.org @ 2021-01-30 12:40 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33661 Florian Weimer <fw at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nate at verse dot com --- Comment #20 from Florian Weimer <fw at gcc dot gnu.org> --- *** Bug 58118 has been marked as a duplicate of this bug. *** ^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/33661] template methods forget explicit local register asm vars [not found] <bug-33661-4@http.gcc.gnu.org/bugzilla/> ` (7 preceding siblings ...) 2021-01-30 12:40 ` fw at gcc dot gnu.org @ 2021-04-20 23:31 ` cvs-commit at gcc dot gnu.org 2021-04-22 16:50 ` cvs-commit at gcc dot gnu.org ` (2 subsequent siblings) 11 siblings, 0 replies; 12+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2021-04-20 23:31 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33661 --- Comment #21 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-9 branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:ef5db37cc4e80b229502bea7d6e2daa95ad6f805 commit r9-9412-gef5db37cc4e80b229502bea7d6e2daa95ad6f805 Author: Jakub Jelinek <jakub@redhat.com> Date: Thu Jan 28 16:13:11 2021 +0100 c++: Fix up handling of register ... asm ("...") vars in templates [PR33661, PR98847] As the testcase shows, for vars appearing in templates, we don't attach the asm spec string to the pattern decls, nor pass it back to cp_finish_decl during instantiation. The following patch does that. 2021-01-28 Jakub Jelinek <jakub@redhat.com> PR c++/33661 PR c++/98847 * decl.c (cp_finish_decl): For register vars with asmspec in templates call set_user_assembler_name and set DECL_HARD_REGISTER. * pt.c (tsubst_expr): When instantiating DECL_HARD_REGISTER vars, pass asmspec_tree to cp_finish_decl. * g++.target/i386/pr98847.C: New test. (cherry picked from commit cf93f94b3498f3925895fb0bbfd4b64232b9987a) ^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/33661] template methods forget explicit local register asm vars [not found] <bug-33661-4@http.gcc.gnu.org/bugzilla/> ` (8 preceding siblings ...) 2021-04-20 23:31 ` cvs-commit at gcc dot gnu.org @ 2021-04-22 16:50 ` cvs-commit at gcc dot gnu.org 2021-04-22 17:05 ` jakub at gcc dot gnu.org 2021-09-11 14:29 ` pinskia at gcc dot gnu.org 11 siblings, 0 replies; 12+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2021-04-22 16:50 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33661 --- Comment #22 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-8 branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:712ffc0ad150aadfa5b91f493075e88fd050189f commit r8-10878-g712ffc0ad150aadfa5b91f493075e88fd050189f Author: Jakub Jelinek <jakub@redhat.com> Date: Thu Jan 28 16:13:11 2021 +0100 c++: Fix up handling of register ... asm ("...") vars in templates [PR33661, PR98847] As the testcase shows, for vars appearing in templates, we don't attach the asm spec string to the pattern decls, nor pass it back to cp_finish_decl during instantiation. The following patch does that. 2021-01-28 Jakub Jelinek <jakub@redhat.com> PR c++/33661 PR c++/98847 * decl.c (cp_finish_decl): For register vars with asmspec in templates call set_user_assembler_name and set DECL_HARD_REGISTER. * pt.c (tsubst_expr): When instantiating DECL_HARD_REGISTER vars, pass asmspec_tree to cp_finish_decl. * g++.dg/opt/pr98847.C: New test. (cherry picked from commit cf93f94b3498f3925895fb0bbfd4b64232b9987a) ^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/33661] template methods forget explicit local register asm vars [not found] <bug-33661-4@http.gcc.gnu.org/bugzilla/> ` (9 preceding siblings ...) 2021-04-22 16:50 ` cvs-commit at gcc dot gnu.org @ 2021-04-22 17:05 ` jakub at gcc dot gnu.org 2021-09-11 14:29 ` pinskia at gcc dot gnu.org 11 siblings, 0 replies; 12+ messages in thread From: jakub at gcc dot gnu.org @ 2021-04-22 17:05 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33661 Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |jakub at gcc dot gnu.org Resolution|--- |FIXED --- Comment #23 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Fixed. ^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/33661] template methods forget explicit local register asm vars [not found] <bug-33661-4@http.gcc.gnu.org/bugzilla/> ` (10 preceding siblings ...) 2021-04-22 17:05 ` jakub at gcc dot gnu.org @ 2021-09-11 14:29 ` pinskia at gcc dot gnu.org 11 siblings, 0 replies; 12+ messages in thread From: pinskia at gcc dot gnu.org @ 2021-09-11 14:29 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33661 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |8.5 ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2021-09-11 14:29 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <bug-33661-4@http.gcc.gnu.org/bugzilla/> 2011-08-24 10:09 ` [Bug c++/33661] template methods forget explicit local reg vars s.schuh85 at gmail dot com 2012-05-31 8:19 ` Aleksandrs.Saveljevs at gmail dot com 2014-10-26 14:25 ` adam at os dot inf.tu-dresden.de 2015-06-03 10:05 ` pinskia at gcc dot gnu.org 2020-04-11 6:13 ` [Bug c++/33661] template methods forget explicit local register asm vars mp8191mp at gmail dot com 2021-01-28 15:14 ` cvs-commit at gcc dot gnu.org 2021-01-29 19:20 ` cvs-commit at gcc dot gnu.org 2021-01-30 12:40 ` fw at gcc dot gnu.org 2021-04-20 23:31 ` cvs-commit at gcc dot gnu.org 2021-04-22 16:50 ` cvs-commit at gcc dot gnu.org 2021-04-22 17:05 ` jakub at gcc dot gnu.org 2021-09-11 14:29 ` pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).