[Bug c++/94100] New: ICE: tree check: accessed elt 1 of 'tree_vec' with 0 elts in tsubst_pack_expansion, at cp/pt.c:12765
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94100 Bug ID: 94100 Summary: ICE: tree check: accessed elt 1 of 'tree_vec' with 0 elts in tsubst_pack_expansion, at cp/pt.c:12765 Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jjk at acm dot org Target Milestone: --- Created attachment 47998 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47998=edit Source file to be compiled. The attached file elicits an ICE in the GCC "trunk" version used by Compiler Explorer (https://godbolt.org/z/iPK_JV): : In function 'int main()': :20:24: internal compiler error: tree check: accessed elt 1 of 'tree_vec' with 0 elts in tsubst_pack_expansion, at cp/pt.c:12765 20 | Foo::foo(); |^ Please submit a full bug report, with preprocessed source if appropriate. See <https://gcc.gnu.org/bugs/> for instructions. When using GCC 9.2, no ICE happens, but the file fails to be parsed: : In function 'int main()': :20:24: error: no matching function for call to 'Foo::foo()' 20 | Foo::foo(); |^ :11:3: note: candidate: 'template static void Foo::foo() [with ARGS ...args = {args ...}; ARGS = {bool}]' 11 | foo(void) | ^~~ :11:3: note: template argument deduction/substitution failed: :21:31: error: no matching function for call to 'Foo::foo<42, 23>()' 21 | Foo::foo<42, 23>(); | ^ :11:3: note: candidate: 'template static void Foo::foo() [with ARGS ...args = {args ...}; ARGS = {int, long int}]' 11 | foo(void) | ^~~ :11:3: note: template argument deduction/substitution failed: :21:31: error: wrong number of template arguments (2, should be 1) 21 | Foo::foo<42, 23>(); | ^ :22:34: error: no matching function for call to 'Foo::foo<'h', 'i'>()' 22 | Foo::foo<'h', 'i'>(); | ^ :11:3: note: candidate: 'template static void Foo::foo() [with ARGS ...args = {args ...}; ARGS = {char, char}]' 11 | foo(void) | ^~~ :11:3: note: template argument deduction/substitution failed: :22:34: error: wrong number of template arguments (2, should be 1) 22 | Foo::foo<'h', 'i'>(); | ^ Clang correctly compiles the file.
[Bug other/46847] New: Missed optimization for variant of Duff's device
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46847 Summary: Missed optimization for variant of Duff's device Product: gcc Version: 4.3.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other AssignedTo: unassig...@gcc.gnu.org ReportedBy: j...@acm.org The attached file contains a function that implements a variant of Duff's device to zero out part of an array. GCC 4.3.2 (Red Hat 4.3.2-7) with -O3 generates rather bad code for x86-64; the code it produces for i386 might also be improved. Generated code for -m32 and -m64 is in the attached file. The -m64 version contains multiple copies of a redundant load for %esi (and corresponding jumps). Both versions move the computation of 'end' inside the loop, which seems unnecessary to me.
[Bug other/46847] Missed optimization for variant of Duff's device
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46847 --- Comment #1 from Jens Kilian jjk at acm dot org 2010-12-08 09:12:07 UTC --- Created attachment 22681 -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=22681 Source code and generated assembly
[Bug other/46847] Missed optimization for variant of Duff's device
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46847 --- Comment #3 from Jens Kilian jjk at acm dot org 2010-12-08 12:10:02 UTC --- (In reply to comment #2) GCC 4.5 doesn't move end computation inside the loop. What do you expect to be good code? I get at -O[23]: [snip] The code generated by 4.5 is what I would have expected. Feel free to close this as fixed in the latest version. Duffs device may be a fun thing from a C language perspective, but it is a bad thing in general because you defy most loop optimizations as it is a loop with multiple entries (which means the loop isn't recognized as a loop by GCC). I usually wouldn't consider using it, I just noticed the problem while trying to tune some heavily used parts of our code. Thanks, Jens.
[Bug c/37823] New: Missed optimization - ffs() from strings.h
GCC produces some redundant addl/subl instructions for the following function, which calls the built-in ffs(): --- snip --- #include strings.h int foo(int i, int j) { return i + ffs(j) - 1; } --- output of gcc -O3 -m32 -S foo.c --- foo: pushl %ebp xorl%edx, %edx movl%esp, %ebp bsfl12(%ebp), %eax sete%dl negl%edx orl %edx, %eax addl$1, %eax subl$1, %eax addl8(%ebp), %eax popl%ebp ret --- output of gcc -O3 -S foo.c --- foo: bsfl%esi, %esi movl$-1, %eax cmove %eax, %esi addl$1, %esi leal-1(%rsi,%rdi), %eax ret -- Summary: Missed optimization - ffs() from strings.h Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jjk at acm dot org GCC host triplet: x86_64-redhat-linux GCC target triplet: x86_64-redhat-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37823
[Bug c/36651] New: 64-bit enumerator incorrectly demoted to 32 bits
This problem can be reproduced using the attached testcase. In GCC 3.2.3 (i386-redhat-linux), it works as expected: ~ % gcc -v Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux Thread model: posix gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-54) ~ % gcc -o foo foo.c ~ % ./foo 10002 10002 In GCC 4.1.2 (x86_64-redhat-linux), apparently the value FOO is interpreted as a 32-bit integer before the left shift; the bizarre thing is that casting to Foo (which should be unnecessary) avoids this. ~ % gcc -v Using built-in specs. Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=x86_64-redhat-linux Thread model: posix gcc version 4.1.2 20070626 (Red Hat 4.1.2-14) ~ % gcc -o foo foo.c foo.c: In function 'main': foo.c:13: warning: left shift count = width of type ~ % ./foo 2 10002 When I asked about this on gcc-help, Andrew Haley [EMAIL PROTECTED] wrote: It's a bug. C99 says an enumerated type shall be large enough to represent all its members, and that when promoting the rank of the enumerated type shall equal the rank of the compatible integer type. -- Summary: 64-bit enumerator incorrectly demoted to 32 bits Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jjk at acm dot org GCC host triplet: x86_64-redhat-linux GCC target triplet: x86_64-redhat-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36651
[Bug c/36651] 64-bit enumerator incorrectly demoted to 32 bits
--- Comment #1 from jjk at acm dot org 2008-06-27 12:36 --- Created an attachment (id=15820) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15820action=view) Test case. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36651
[Bug c++/36449] New: Incorrect code generated for access to a large struct
Please refer to the attached example. When the struct 'ZIP' in this example is enlarged by one word, G++ silently generates incorrect code. -- Summary: Incorrect code generated for access to a large struct Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jjk at acm dot org GCC host triplet: x86_64-redhat-linux GCC target triplet: x86_64-redhat-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36449
[Bug c++/36449] Incorrect code generated for access to a large struct
--- Comment #1 from jjk at acm dot org 2008-06-06 13:28 --- Created an attachment (id=15725) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15725action=view) C++ code for reproducing the problem. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36449
[Bug c++/36046] New: Demangler fails on templates with non-type reference parameters
See attached test case. -- Summary: Demangler fails on templates with non-type reference parameters Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jjk at acm dot org GCC host triplet: x86_64-redhat-linux GCC target triplet: x86_64-redhat-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36046
[Bug c++/36046] Demangler fails on templates with non-type reference parameters
--- Comment #1 from jjk at acm dot org 2008-04-25 13:57 --- Created an attachment (id=15531) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15531action=view) Test case. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36046
[Bug c++/20004] New: G++ disregards __attribute__((regparm(3))) when calling through a const pointer
Output from g++ -v: Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux Thread model: posix gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-20) Compile the following code using g++ -S bug.c: ---8---bug.c--8--- struct Foo { int __attribute__((regparm(3))) (*p)(int); }; extern struct Foo *foo; extern const struct Foo *bar; int baz(int i) { return (foo-p)(i); } int zip(int i) { return (bar-p)(i); } ---8--8--- The only difference between baz() and zip() is that baz() uses a struct Foo * while zip() uses a const struct Foo *. However, in the generated assembler code, baz() passes parameters in registers as requested, and zip() doesn't. _Z3bazi: [...] movlfoo, %eax movl(%eax), %edx movl8(%ebp), %eax call*%edx _Z3zipi: [...] movlbar, %eax pushl 8(%ebp) movl(%eax), %eax call*%eax Note: This bug is specific to the C++ compiler; the C compiler does the right thing. -- Summary: G++ disregards __attribute__((regparm(3))) when calling through a const pointer Product: gcc Version: 3.2.3 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jjk at acm dot org CC: gcc-bugs at gcc dot gnu dot org GCC host triplet: i386-redhat-linux GCC target triplet: i386-redhat-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20004