Warning C4430 not being thrown in friend declaration

class myClass;

class otherClass{

public:

otherClass(int x): valor(x){}

inlineint sum(myClass&obj);

private:

int valor;

};

class myClass{

public:

myClass(int x): val(x){}

friend otherClass::sum(myClass&);

private:

int val;

};

inlineint otherClass::sum(myClass&obj){

return obj.val+ valor;

}

The above is a minimalist example to illustrate the problem at hand.

Note how the friend declaration is not defining the return type of otherClass::sum() and yet Warning C4430 is not being thrown.

Is this a bug? Or is there some compiler option I'm setting that precludes the warning?

This is my compiler's command line:

/Od /D "_WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /FD /EHsc /MDd /Gy /Za /Fo"Debug\\" /Fd"Debug\vc80.pdb" /W4 /nologo /c /Zi /TP /errorReport:prompt

[4564 byte] By [Marfig] at [2007-12-21]
# 1
A friend function declaration requires a function-declarator. Since functions cannot be overloaded by return type, a return type declaration is not needed. If you include one, it is checked, possibly generating C2556.
nobugz at 2007-9-10 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 2

Curious, because this piece of code, generates C4430:

class foo
{
friend operator==(const foo& f1, const foo& f2);
};

MariusBancila at 2007-9-10 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 3

nobugz wrote:
A friend function declaration requires a function-declarator. Since functions cannot be overloaded by return type, a return type declaration is not needed. If you include one, it is checked, possibly generating C2556.

Wouldn't that be the same as state that any function declaration does not require a return type? We know that is not true. Previous compilers assumed int. That is no longer the case.

When I include the return type, no warning is generated. Which is as expected, since when I include the return type I'm following ISO (read 7.1 and 11.4).

Marfig at 2007-9-10 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 4
Posted bug report with same title
Marfig at 2007-9-10 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 5
I just saw this. Yep it's a bug and it still repro's with the latest build of the compiler.
JonathanCaves-MSFT at 2007-9-10 > top of Msdn Tech,Visual C++,Visual C++ Language...