Works gcc 4.2 20060806, fails with 20060823: (sid)579:tbm@usurper: ~] /usr/lib/gcc-snapshot/bin/g++ -c texlive-t1rw.cc texlive-t1rw.cc:19: error: conflicting declaration 'unsigned char Efont::Type1Reader::xvalue_store [257]' texlive-t1rw.cc:5: error: 'Efont::Type1Reader::xvalue_store' has a previous declaration as 'unsigned char Efont::Type1Reader::xvalue_store [(sizeof (T) * want)]' texlive-t1rw.cc:19: error: declaration of 'unsigned char Efont::Type1Reader::xvalue_store [(sizeof (T) * want)]' outside of class is not definition texlive-t1rw.cc:19: internal compiler error: tree check: did not expect class 'type', have 'type' (template_type_parm) in contains_placeholder_p, at tree.c:2223 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Created attachment 12156 [details] test case Testcase from application "texlive-bin".
Reduced testcase: extern unsigned char xvalue_store[]; bool reserve (int want) { new unsigned char[want]; } unsigned char xvalue_store[257]; ---- I almost think this was casued by the patch to fix PR 27184. Janis, Could you do a regression hunt on this bug? Thanks, Andrew
*** Bug 28907 has been marked as a duplicate of this bug. ***
This also causes wrong code: extern char machineMain[]; void sort (long len) { new char[100]; } char machineMain[] = "main"; int main(void) { if (sizeof(machineMain)!=sizeof("main")) __builtin_abort(); }
Yes this was casued by that patch. Anyways we do: 1627 /* ??? The middle-end will error on us for building a VLA outside a 1628 function context. Methinks that's not it's purvey. So we'll do 1629 our own VLA layout later. */ 1630 vla_p = true; (gdb) l 1631 full_type = build_cplus_array_type (type, NULL_TREE); 1632 index = convert (sizetype, nelts); 1633 index = size_binop (MINUS_EXPR, index, size_one_node); 1634 TYPE_DOMAIN (full_type) = build_index_type (index); Which is the problem. I will look into this further either this long weekend or later today.
Doing: Index: init.c =================================================================== --- init.c (revision 116553) +++ init.c (working copy) @@ -1628,7 +1628,7 @@ build_new_1 (tree placement, tree type, function context. Methinks that's not it's purvey. So we'll do our own VLA layout later. */ vla_p = true; - full_type = build_cplus_array_type (type, NULL_TREE); + full_type = copy_node (build_cplus_array_type (type, NULL_TREE)); index = convert (sizetype, nelts); index = size_binop (MINUS_EXPR, index, size_one_node); TYPE_DOMAIN (full_type) = build_index_type (index); Will fix the problem but I don't know if this is the correct fix.
Mine, we want/need to use build_distinct_type_copy instead but other than that it should be ok.
Is this the same bug? (sid)59:tbm@usurper: ~/delta/bin] /usr/lib/gcc-snapshot/bin/g++ -c mini.c mini.c:40: error: variable-size type declared outside of any function mini.c:40: error: variable-size type declared outside of any function Testcase: extern "C" { typedef long unsigned int size_t; extern size_t strlen (__const char *__s) throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); struct addrinfo { } _G_fpos64_t; typedef unsigned char cc_t; } extern char *hostname; extern char NetTraceFile[]; void SetNetTrace (const char *); typedef struct { } Clocks; char **genget (const char *, char **, int); struct setlist { const char *name; const char *help; void (*handler) (const char *); cc_t *charp; }; static struct setlist Setlist[] = { { "tracefile", "file to write trace information to", SetNetTrace, (cc_t *) NetTraceFile} }; static struct setlist * getset (const char *name) { return (struct setlist *) genget (name, (char **) Setlist, sizeof (struct setlist)); char *hostp = __null; { hostname = new char[strlen (hostp) + 1]; } }
Created attachment 12163 [details] preprocessed source Actually, can you please check when you get home if this is the same bug?
(In reply to comment #9) > Actually, can you please check when you get home if this is the same bug? Yes this is the same bug as my patch (which I am about to submut) fixes it.
I did not add a testcase for one that just ICE but I did add two testcases, one for the wrong code and one for the rejecting valid. The ICE is because of templates which I don't feel like needing a testcase for that really since the other two should be enough to detect the problem in the future. I also added a testcase to make sure that two seperate variables does change the shared incomplete shared type either.
Subject: Bug number PR C++/28906 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-09/msg00007.html
Subject: Bug 28906 Author: pinskia Date: Fri Sep 8 02:49:11 2006 New Revision: 116776 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116776 Log: 006-09-07 Andrew Pinski <pinskia@physics.uc.edu> PR C++/28906 * init.c (build_new_1): Build a distinct type copy for the array type that was returned from build_cplus_array_type. 2006-09-07 Andrew Pinski <pinskia@physics.uc.edu> PR C++/28906 * g++.dg/other/array3.C: New test. * g++.dg/other/array4.C: New test. * g++.dg/other/array5.C: New test. Added: trunk/gcc/testsuite/g++.dg/other/array3.C trunk/gcc/testsuite/g++.dg/other/array4.C trunk/gcc/testsuite/g++.dg/other/array5.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/init.c trunk/gcc/testsuite/ChangeLog
Fixed.
Subject: Bug 28906 Author: rguenth Date: Tue Oct 17 08:27:26 2006 New Revision: 117821 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117821 Log: 2006-10-17 Richard Guenther <rguenther@suse.de> Backport from mainline: 2006-09-07 Andrew Pinski <pinskia@physics.uc.edu> PR C++/28906 * init.c (build_new_1): Build a distinct type copy for the array type that was returned from build_cplus_array_type. * g++.dg/other/array3.C: New test. * g++.dg/other/array4.C: New test. * g++.dg/other/array5.C: New test. Added: branches/gcc-4_1-branch/gcc/testsuite/g++.dg/other/array3.C - copied unchanged from r116776, trunk/gcc/testsuite/g++.dg/other/array3.C branches/gcc-4_1-branch/gcc/testsuite/g++.dg/other/array4.C - copied unchanged from r116776, trunk/gcc/testsuite/g++.dg/other/array4.C branches/gcc-4_1-branch/gcc/testsuite/g++.dg/other/array5.C - copied unchanged from r116776, trunk/gcc/testsuite/g++.dg/other/array5.C Modified: branches/gcc-4_1-branch/gcc/cp/ChangeLog branches/gcc-4_1-branch/gcc/cp/init.c branches/gcc-4_1-branch/gcc/testsuite/ChangeLog