This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[3.3] Fix for 10428 breaks template instantiation


Hi Mark,

I noticed that the current 3.3 branch does not compile the below code
anymore:

-------- snip -------
template<typename T>
struct A {
  ~A() {p->unref();};
  T* p;
};

struct B;

struct C {
  C() {}
  A<B> b;
};

struct B{
  void unref(void);
};
void B::unref(void) {}

C c;
-------- snap -------

It now breaks with this error:
opensp-bug.ii:10:   instantiated from here
opensp-bug.ii:3: error: `unref' undeclared (first use this function)
opensp-bug.ii:3: error: (Each undeclared identifier is reported only once
for   each function it appears in.)

It was compiling on the branch from 2003-04-22 but fails on 2003-04-23.
The ChangeLog for cp/ shows this:

+2003-04-22  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/10428
+       * decl.c (check_elaborated_type_specifier): New function, split
+       out from ...
+       (xref_tag): ... here.  Use the new function in more places.
+
+2003-04-21  Mark Mitchell  <mark@codesourcery.com>
+
+       * call.c (build_over_call): Use build_cxx_call.
+       (build_cxx_call): New method, split out of build_over_call.
+       * cp-tree.h (language_function): Add can_throw.
+       (build_cxx_call): Declare it.
+       * decl.c (finish_function): If a function does not contain any
+       calls to functions that can throw an exception, indicate that
+       fact.
+       * decl2.c (mark_used): Do not defer the instantiation of
+       functions, if the current function does not throw.
+       * optimize.c (maybe_clone_body): Copy TREE_NOTHROW to the clones.
+       * pt.c (instantiate_decl): Make sure import_export_decl is called
+       before emitting things.
+       * rtti.c (throw_bad_cast): Use build_cxx_call.
+       (build_dynamic_cast_1): Likewise.
+       * typeck.c (build_function_call): Likewise.

If I revert back just the cp/ directory before those patches went in, it
works again.  I'm not totally sure if this is even valid C++, although it
worked before.  After all, the ~A() calls a function on a still
incomplete type, although if one would defer the instantiation of A<B> to
the place where actually needed (the "C c;") B would be complete.  I just
want to be sure, that it's really invalid C++, and not just an oversight
in your patches.  (The testcase was constructed out of OpenSP, i.e.
there's at least one real world case using this possibly broken code).


Ciao,
Michael.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]