Weird error message with VC7.1

H

Hendrik Schober

Hi,

I have some expression template code that I want to
get to work. I had a typo in it and just spent two
hours to find it, because VC7.1 gave a really weird
error message for it.
This is the code:

template< typename T1, typename TExpr, typename T2>
inline
Detail::CExpression< T2, Detail::CExpression<T1,TExpr> >
operator+( const Detail::CExpression<T1,TExpr>& expr
, const CNamedTypedParameter<T2>& par )
{
return Detail::CExpression< T2, Detail::CExpression<T1,TExpr> >( par, expr );
//return Detail::CExpression< T2, Detail::CExpression<T1,TExpr>( par, expr);
}

The code compiles fine as it is. Uncommenting commented
line (which misses a closing bracket) causes
error C2665: 'Detail::CExpression<T,TExpr>::__ctor' :
none of the 2 overloads can convert parameter 2 from type 'const Detail::CExpression<T,TExpr>'

OK, by the standard, this should be fine. I fed the
compiler none-conforming code and it spit out a
diagnostic. However, it's a very misleading one!

Did anybody else see something like this? Is it worth
spending the time to distill a repro from the code?

Schobi

--
(e-mail address removed) is never read
I'm Schobi at suespammers org

"My hair style calls into immediate question all my judgements."
Scott Meyers
(http://www.google.de/[email protected])
 
J

Jonathan Caves [MSFT]

From: "Hendrik Schober said:
Subject: Weird error message with VC7.1
Date: Mon, 11 Aug 2003 17:06:14 +0200
Lines: 41

Hi,

OK, by the standard, this should be fine. I fed the
compiler none-conforming code and it spit out a
diagnostic. However, it's a very misleading one!

Did anybody else see something like this? Is it worth
spending the time to distill a repro from the code?

Schobi

--

Getting decent compiler diagnostics for template error messages is a
problem for all C++ compilers
not just for the Visual C++ compiler -- the problem with templates and
especially with deeply nested
templates is that the compiler can very quickly lose the context of the
user code: one rather simple
line of user code can cause the compiler to go off an instantiate 10's if
not 100's of other class
templates. We are trying to do a better job with each release: hopefully at
some point all compilers
will have clean, concise, actionable error messages for all template
diagnostics.
 
H

Hendrik Schober

Hi Jonathan,
[...]
Getting decent compiler diagnostics for template error messages is a
problem for all C++ compilers
not just for the Visual C++ compiler

Oh, I had to learn that already! :blush:>
-- the problem with templates and
especially with deeply nested
templates is that the compiler can very quickly lose the context of the
user code: one rather simple
line of user code can cause the compiler to go off an instantiate 10's if
not 100's of other class
templates.

I don't think that's the case here. In fact, I
think the message came up with rather simple
code. (I was, after all, still able to understand
what really was going on, once I found the typo.
And I'm usually quite bad with understanding that
template meta stuff...)
We are trying to do a better job with each release: hopefully at
some point all compilers
will have clean, concise, actionable error messages for all template
diagnostics.

Well, I'd settle for the compilers I have to use. :^>
Jonathan Caves, Visual C++ Team

Schobi

--
(e-mail address removed) is never read
I'm Schobi at suespammers org

"My hair style calls into immediate question all my judgements."
Scott Meyers
(http://www.google.de/[email protected])
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top