struct A {}; template <class T> struct B : public T { B (); }; B<A* foo () { return new B<A>(); } template <class T> B<T>::B () { } template <> B<A>::B () { } ICEs at i inline_forbidden_p: 1448 FR_EACH_BB_FN (bb, DECL_STRUCT_FUNCTIN (fndecl)) as fndecl (B ctor) doesn't have cfg set (DECL_STRUCT_FUNCTIN (fndecl)->cfg == NULL).
No.1 | | 167 bytes | |
-- pinskia at gcc dot gnu dot org changed: What |Removed |Added Component|tree-optimization |c++ Target Milestone| |4.1.2
No.2 | | 74 bytes | |
Comment #2 from bangerth at dealii dot org 2006-06-16 22:51 Confirmed.
No.3 | | 471 bytes | |
Comment #3 from bangerth at dealii dot org 2006-06-16 22:55 The code is invalid, however: explicit specializations must be declared before they are first used. In the snippet, B<A>::B is used in foo() before the specialization is declared. The ICE consequently also goes away if a declaration (not definition) of the specialization precedes foo().
That all doesn't make it any more forgivable that we ICE on this code, however.
W.
No.4 | | 122 bytes | |
Comment #4 from pinskia at gcc dot gnu dot org 2006-06-24 23:53 Bug 28159 has been marked as a duplicate of this bug.
No.5 | | 457 bytes | |
Comment #5 from reichelt at gcc dot gnu dot org 2006-07-12 16:39 Here's a testcase that crashes even at since GCC 4.1.0:
template<intstruct A { A() {} };
A<0a;
template<A<0>::A() {}
As Wolfgang already mentioned: explicit specializations must be declared before they are first used. However, no diagnostic is required. (Which indicates that such situations are hard to detect reliably.)
No.6 | | 122 bytes | |
-- mmitchel at gcc dot gnu dot org changed: What |Removed |Added Priority|P3 |P2
No.7 | | 583 bytes | |
Comment #6 from hubicka at gcc dot gnu dot org 2006-07-21 20:36 cgraph_analyze_function is reentrant for non-unit-at-a-time support. However with unit-at-a-time, the analysis happens only after unit has been finalized and at that time frontend is not supposed to come up with new functions anymore. It would be a lot better to make C++ frontend to handle this case early (probably diagnose the invalid code?), but I don't quite understand this area of compiler, so if someone C++ aware would tell me it is dificult, we can do it as workaround.
Honza
No.8 | | 307 bytes | |
Comment #7 from janis at gcc dot gnu dot org 2006-08-14 16:16 Regression hunts on powerpc-linux showed that the original testcase with and the testcase in comment #5 with both start getting segfaults with the following patch:
-- mmitchel at gcc dot gnu dot org changed: What |Removed |Added AssignedTo|unassigned at gcc dot gnu |mark at codesourcery dot com |dot org | Status|NEW |ASSIGNED
No.10 | | 514 bytes | |
Comment #8 from mmitchel at gcc dot gnu dot org 2006-08-26 16:53 We do have code to notice use-before-specialization errors. For example:
However, the code to initialize static variables is not generated until end-of-file, so we do not realize that we are in this situation. (See expand_static_init for the point at which we defer initialization.)
No.11 | | 565 bytes | |
Comment #9 from mmitchel at gcc dot gnu dot org 2006-08-27 17:45 Subject: Bug 28058
Author: mmitchel Date: Sun Aug 27 17:45:25 2006 New Revision: 116491
URL: Log: PR c++/28058 * pt.c (register_specialization): Return error_mark_node for
* decl2.c (mark_used): Mark the main function used when one of its clones is used.