Why does this code even compile? 
Author Message
 Why does this code even compile?

This code compiles with no error, the functoin body of operator Sptr<T2> ()
seem to be ignored by compiler, any idea? Thanks.

template < class T >
class Sptr
{
private:
    T* ptr;
public:
    template < class T2 >
    operator Sptr<T2> () const
    {
        junk junk, you can put any thing here
        return Sptr < T2 > (ptr);
    }

    // ...

Quote:
}



Sun, 01 Feb 2004 10:11:30 GMT  
 Why does this code even compile?
I would consider this a bug.  We only do syntax checking on some
uninstantiated template constructs.  In this case, we aren't doing any
syntax checking on member templates.  If you were to specialize the member
template, you would get the proper errors.

I should add that we don't properly support template udc operators in VC7,
but we will in VC7.1.

Jason Shirk
VC++ Compiler Team


Quote:
> This code compiles with no error, the functoin body of operator Sptr<T2>
()
> seem to be ignored by compiler, any idea? Thanks.

> template < class T >
> class Sptr
> {
> private:
>     T* ptr;
> public:
>     template < class T2 >
>     operator Sptr<T2> () const
>     {
>         junk junk, you can put any thing here
>         return Sptr < T2 > (ptr);
>     }

>     // ...
> }



Mon, 02 Feb 2004 00:59:30 GMT  
 Why does this code even compile?
Thanks.
I tried my code with both VC6 and VC7, and didn't work, so I thought it was
me. Only question is now when we can have 7.1, shortly after release of 7 or
still in unknown future.



Quote:
> I would consider this a bug.  We only do syntax checking on some
> uninstantiated template constructs.  In this case, we aren't doing any
> syntax checking on member templates.  If you were to specialize the member
> template, you would get the proper errors.

> I should add that we don't properly support template udc operators in VC7,
> but we will in VC7.1.

> Jason Shirk
> VC++ Compiler Team



> > This code compiles with no error, the functoin body of operator Sptr<T2>
> ()
> > seem to be ignored by compiler, any idea? Thanks.

> > template < class T >
> > class Sptr
> > {
> > private:
> >     T* ptr;
> > public:
> >     template < class T2 >
> >     operator Sptr<T2> () const
> >     {
> >         junk junk, you can put any thing here
> >         return Sptr < T2 > (ptr);
> >     }

> >     // ...
> > }



Mon, 02 Feb 2004 02:29:15 GMT  
 Why does this code even compile?
We do not as yet have a schedule for release of the next version of the
Visual C++ (tentatively called 7.1) - but it is safe to say that you will
not have to wait as long as you did for 7.0 - we are definitely hoping for
sooner rather than later.

--
Jonathan Caves
Microsoft Corporation

This posting is covered by the Conditions of Use:
http://www.microsoft.com/info/cpyright.htm.


Quote:
> Thanks.
> I tried my code with both VC6 and VC7, and didn't work, so I thought it
was
> me. Only question is now when we can have 7.1, shortly after release of 7
or
> still in unknown future.


message

> > I would consider this a bug.  We only do syntax checking on some
> > uninstantiated template constructs.  In this case, we aren't doing any
> > syntax checking on member templates.  If you were to specialize the
member
> > template, you would get the proper errors.

> > I should add that we don't properly support template udc operators in
VC7,
> > but we will in VC7.1.

> > Jason Shirk
> > VC++ Compiler Team



> > > This code compiles with no error, the functoin body of operator
Sptr<T2>
> > ()
> > > seem to be ignored by compiler, any idea? Thanks.

> > > template < class T >
> > > class Sptr
> > > {
> > > private:
> > >     T* ptr;
> > > public:
> > >     template < class T2 >
> > >     operator Sptr<T2> () const
> > >     {
> > >         junk junk, you can put any thing here
> > >         return Sptr < T2 > (ptr);
> > >     }

> > >     // ...
> > > }



Mon, 02 Feb 2004 07:12:32 GMT  
 Why does this code even compile?
According to the C++ standard, if a template member function is not used it
is not even instantiated. It can however be syntax checked, but according to
the standard the degree of checking is left entirely to the implementor of
the compiler. The compiler certainly doesn't have to do any semantic
checking, so this could even pass as NOT a bug.


Quote:
> This code compiles with no error, the functoin body of operator Sptr<T2>
()
> seem to be ignored by compiler, any idea? Thanks.

> template < class T >
> class Sptr
> {
> private:
>     T* ptr;
> public:
>     template < class T2 >
>     operator Sptr<T2> () const
>     {
>         junk junk, you can put any thing here
>         return Sptr < T2 > (ptr);
>     }

>     // ...
> }



Mon, 02 Feb 2004 08:00:18 GMT  
 Why does this code even compile?



Quote:
> We do not as yet have a schedule for release of the next version of the
> Visual C++ (tentatively called 7.1) - but it is safe to say that you will
> not have to wait as long as you did for 7.0 - we are definitely hoping for
> sooner rather than later.

> --
> Jonathan Caves
> Microsoft Corporation

Is 7.1 the version which will address most of the standard C++ issues
remaining in 7.0. Or won't that happen until 8.0?

Bo-Staffan



Mon, 02 Feb 2004 23:48:44 GMT  
 Why does this code even compile?
This is no longer the case - the C++ Standard defines the concept of
dependent and non-dependent names within the context of template definitions
(14.6.2). A non-dependent name is an identifier that does not in anyway
dependent on a template parameter. Such names must be bound at the point of
definition of the template - this requires compilers to perform quite a bit
of syntactic and semantic analysis of all template definitions.

--
Jonathan Caves
Microsoft Corporation

This posting is covered by the Conditions of Use:
http://www.microsoft.com/info/cpyright.htm.


Quote:
> According to the C++ standard, if a template member function is not used
it
> is not even instantiated. It can however be syntax checked, but according
to
> the standard the degree of checking is left entirely to the implementor of
> the compiler. The compiler certainly doesn't have to do any semantic
> checking, so this could even pass as NOT a bug.



> > This code compiles with no error, the functoin body of operator Sptr<T2>
> ()
> > seem to be ignored by compiler, any idea? Thanks.

> > template < class T >
> > class Sptr
> > {
> > private:
> >     T* ptr;
> > public:
> >     template < class T2 >
> >     operator Sptr<T2> () const
> >     {
> >         junk junk, you can put any thing here
> >         return Sptr < T2 > (ptr);
> >     }

> >     // ...
> > }



Mon, 02 Feb 2004 23:50:50 GMT  
 Why does this code even compile?
It will happen in the release that is tentatively called 7.1. But seeing
product naming decisions, and how close to shipping they generally get
changed,  would surprise me as going out under that name.<g>

-Ronald-



Quote:



> > We do not as yet have a schedule for release of the next version of the
> > Visual C++ (tentatively called 7.1) - but it is safe to say that you
will
> > not have to wait as long as you did for 7.0 - we are definitely hoping
for
> > sooner rather than later.

> > --
> > Jonathan Caves
> > Microsoft Corporation

> Is 7.1 the version which will address most of the standard C++ issues
> remaining in 7.0. Or won't that happen until 8.0?

> Bo-Staffan



Tue, 03 Feb 2004 01:19:22 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Why does this code not compile?

2. Why is this code fragment not compiling?

3. Why won't this code compile?

4. Why does not the code compile?

5. Why will MSDN code not compile?

6. ADO Tutorial won't even compile

7. warning C4702: unreachable code in Visual Studio .NET 2002, even with /EHac

8. library compiled with cc linked with code compile with acc

9. Odd or even code?

10. Why is it doing this?

11. Why does doing this break my program?

12. Why are most HPC done in Fortran?

 

 
Powered by phpBB® Forum Software