Valentin David <valentin.david(a)gmail.com> writes:
| Hi,
|
| I did not understand some behaviors of Gcc. Gcc accepts this:
|
| -->8--
| class A {};
| class B {};
| A B;
| -->8--
|
| I found nothing in the standard that says it is not valid. Ok.
In fact the C++ standard says it is valid, see 3.3/4
| According to the standard this one is valid, and Gcc accepts it:
|
| -->8--
| typedef int T;
| typedef int T;
| -->8--
Indeed.
| It does not accept this one:
|
| -->8--
| typedef int T;
| T T;
| -->8--
|
| That is ok, T is a typedef-name.
and because of 3.3/4
| But on this one, it fails:
| -->8--
| class A {};
| typedef A T;
| T T;
| -->8--
|
| But normally, T is class-name.
Yes, but that is only half of the story. The other half is 3.3/4 since
T is also a typedef-name.
| And the same on this one:
|
| -->8--
| typedef class {} A;
| A A;
| -->8--
|
| But here, A is not only a class-name, it is *THE* real name of the class.
Same reason.
| I do not understand why Gcc does not accept these two last examples. I
| did not find it in the standard. If someone find it somewhere...
See 3.3/4.
-- Gaby