[Bug c++/13847] Additions to the changes.html file for 3.4.
giovannibajo at libero dot it
gcc-bugzilla@gcc.gnu.org
Sun Jan 25 16:50:00 GMT 2004
------- Additional Comments From giovannibajo at libero dot it 2004-01-25 16:50 -------
Befriending and explicitly instantiating typedefs won't work anymore.
***********************************************************************
Yes, this could use a changes.html entry. In standardese, GCC 3.4.0 enforces
the standard clause in [basic.lookup.elab]/2 and /3, which talks about
elaborated-type-specifiers (ETS): "If the name lookup finds a typedef-name, the
elaborated-type-specifier is ill-formed."
An ETS is something of the form "class/struct/enum X;". ETS are mainly used for:
- forward declarations (not affected by recent changes).
- friend declarations. Given the bugfix above, GCC 3.4.0 doesn't allow anymore
to befried a class through a typedef name:
class A;
typedef A B;
class C {
friend class B; // ERROR! It used to work.
};
- Explicit instantiations. Again, you can't use typedef names anymore:
template <int> class A {};
typedef A<0> B;
template class B; // ERROR! It used to work.
- As an additional note, ETS are also useful as a workaround if you have a both
a type and a non-type entity bound to the same name.
struct A {};
int A;
void foo(void)
{
A = 0; // OK
A a; // ERROR, lookup finds "int A"
struct A a; // OK, lookup of ETS always finds "struct A".
}
Need a "template <>" before templated static variable definitions.
******************************************************************
This is already documented in changes.html.
The available function overloadings from a call in a template is determined at
definition time not instantiation time, except for Koenig lookup.
******************************************************************************
Ok. I would just say that, in templates, all (modulo bugs) unqualified names
are now looked up in at definition time. This can be added as a rework of the
third C++ entry in changes.html. An example code could be:
void foo(int);
template <int> struct A {
static void bar(void){
foo('a');
}
};
void foo(char);
int main()
{
A<0>::bar(); // Calls foo(int), used to call foo(char).
}
You need to put "class" on explicit instantiations of classes, ie no "template
A<B>;"
******************************************************************************
I didn't even know this was allowed before, must have been a GCC extension. OK,
we can add a entry for this as well.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13847
More information about the Gcc-bugs
mailing list