Illegal code accepted (explicit constructor name) 
Author Message
 Illegal code accepted (explicit constructor name)

Hello,

The following code should be illegal but it's accepted by VC71 final beta.

------------------------------------------------------
template <class>
struct A
{
    A(int) {}

Quote:
};

typedef A<float> AF;

AF a = AF::A(3);
------------------------------------------------------

Can you please confirm and track this?
--
Giovanni Bajo



Mon, 17 Oct 2005 08:47:01 GMT  
 Illegal code accepted (explicit constructor name)
Uh... what exactly is illegal about this? (just curious...)

--
Adam Clauss


Quote:
> Hello,

> The following code should be illegal but it's accepted by VC71 final beta.

> ------------------------------------------------------
> template <class>
> struct A
> {
>     A(int) {}
> };

> typedef A<float> AF;

> AF a = AF::A(3);
> ------------------------------------------------------

> Can you please confirm and track this?
> --
> Giovanni Bajo



Mon, 17 Oct 2005 08:54:04 GMT  
 Illegal code accepted (explicit constructor name)

Quote:

> Uh... what exactly is illegal about this? (just curious...)

You cannot name explicitally a constructor, nor you can get its address.
It's mandated by the standard.

--
Giovanni Bajo



Mon, 17 Oct 2005 09:04:46 GMT  
 Illegal code accepted (explicit constructor name)

Quote:

> Hello,

> The following code should be illegal but it's accepted by VC71 final
> beta.

> ------------------------------------------------------
> template <class>
> struct A
> {
>     A(int) {}
> };

> typedef A<float> AF;

> AF a = AF::A(3);
> ------------------------------------------------------

> Can you please confirm and track this?

Is it accepted with /Za?  The ability to call a constructor explicitly is a
long-time VC extension, I'm sure maintained in 7.1 for backwards
compatiblity.

-cd



Mon, 17 Oct 2005 09:49:21 GMT  
 Illegal code accepted (explicit constructor name)

Quote:
> Is it accepted with /Za?

Yes, still wrongly accepted.

Quote:
> The ability to call a constructor explicitly is a
> long-time VC extension, I'm sure maintained in 7.1 for backwards
> compatiblity.

I could understand that, but it should be disabled with /Za I suppose.
Besides, I completely fail to see the meaning of such an extension. It's not
like it's giving more power to the programmers, is it?

--
Giovanni Bajo



Mon, 17 Oct 2005 09:59:15 GMT  
 Illegal code accepted (explicit constructor name)

Quote:


>> Is it accepted with /Za?

> Yes, still wrongly accepted.

>> The ability to call a constructor explicitly is a
>> long-time VC extension, I'm sure maintained in 7.1 for backwards
>> compatiblity.

> I could understand that, but it should be disabled with /Za I suppose.
> Besides, I completely fail to see the meaning of such an extension.
> It's not like it's giving more power to the programmers, is it?

IIRC, it was used in earlier versions of MFC to do the equivalent of
placement new.

-cd



Mon, 17 Oct 2005 13:06:26 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Explicit constructor calls

2. Explicit constructor invocation

3. VC7.1 C++ bug: incorrect definition of the constructor of a template accepted

4. Possible bug when using explicit fully qualitied names with namesapces

5. DLL function calling problems (explicit - only knowing function name at runtime)

6. "illegal qualified name in member declaration"??

7. Netbios Datagram (illegal name number)

8. explicit runtime condition code checking, particularly overflow

9. Explicit use of Delphi DLL in VC++ code

10. CSocket / Accept, trouble accepting multiple connections

11. Class name in constructor

12. why does gcc accept my code?

 

 
Powered by phpBB® Forum Software