Koenig Lookup in VC++ 2003 Final Beta 
Author Message
 Koenig Lookup in VC++ 2003 Final Beta

Can someone please indicate to me why the following code
issues a warning in VC++ 2003 Final Beta:  (Note the
warning only occurs when compiling in Release mode.)

#include <math.h>

class A
{
public:
        operator double() const
        {
                return 5.0;
        }

Quote:
};

int _tmain(int argc, _TCHAR* argv[])
{
        A a;
        A* pA = &a;
        double x = pow(*pA, 3.0);
        return 0;

Quote:
}

Here is the warning:

warning C4675: 'double pow(double,double)' : resolved
overload was found by argument-dependent lookup
        C:\Program Files\Microsoft Visual Studio .NET 2003
\Vc7\include\math.h(195) : see declaration of 'pow'



Sun, 24 Jul 2005 05:15:10 GMT  
 Koenig Lookup in VC++ 2003 Final Beta

Quote:
> Can someone please indicate to me why the following code
> issues a warning in VC++ 2003 Final Beta:  (Note the
> warning only occurs when compiling in Release mode.)

> #include <math.h>

> class A
> {
> public:
> operator double() const
> {
> return 5.0;
> }
> };

> int _tmain(int argc, _TCHAR* argv[])
> {
> A a;
> A* pA = &a;
> double x = pow(*pA, 3.0);
> return 0;
> }

> Here is the warning:

> warning C4675: 'double pow(double,double)' : resolved
> overload was found by argument-dependent lookup
>         C:\Program Files\Microsoft Visual Studio .NET 2003
> \Vc7\include\math.h(195) : see declaration of 'pow'

AFAIK the conversion function should be found by ordinary unqualified name
lookup. The warning is either spuriously emitted or the name lookup is
incorrect.

Bo-Staffan



Mon, 25 Jul 2005 02:21:42 GMT  
 Koenig Lookup in VC++ 2003 Final Beta


Quote:
> Can someone please indicate to me why the following code
> issues a warning in VC++ 2003 Final Beta:  (Note the
> warning only occurs when compiling in Release mode.)

[snip]

This is a bug.  It looks like intrinsic functions trigger the warning
inappropriately (compiling w/ -Oi is enough to repro.)

The warning is only meant to point out places where a different function is
being called than with VC7 and earlier releases.

We don't expect people to leave warning C4675 enabled after fully porting
code to VC++ 2003.

--
Jason Shirk
VC++ Compiler Team



Mon, 25 Jul 2005 04:14:12 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. VC 2003 final beta

2. Problem with va_list in VC++ 6.0/2002/2003 Final Beta

3. VC++ .Net 2003 Final Beta Issue #2

4. VS 2003 final beta C1001: another ICE

5. Possible C++ bug .NET 2003 Final Beta

6. Syntax Error in Templates in 2003 Final Beta Compiler

7. optimizer bug in VC7.1 final beta Visual Studio .Net 2003

8. Bugs in Visual C++ 2003 Final Beta

9. Possible bug: MIDL properties missing in VS.NET 2003 Final Beta

10. Final Release VC++ 2003 - Internal Compiler Errors

11. Bug in VC++ 2003 Final Beta, or my mistake?

12. VC 7.1 final beta: bug with template template parameters

 

 
Powered by phpBB® Forum Software