all groups > dotnet clr > september 2003 >
You're in the

dotnet clr

group:

Managed C++ potential bug: Lack of "return" statement not an error


Managed C++ potential bug: Lack of "return" statement not an error brikelly NO[at]SPAM hotmail.com
9/26/2003 1:05:58 PM
dotnet clr:
Hi all,

With .NET 1.1, the following code does not give an error
during compilation:

Type*
foo()
{
if (0)
{
throw 1;
}
}

Note the lack of a possible valid return path! Typically, a C++
compiler will flag this with an error such as "not all control paths
return a value". However, with cl.exe and the /clr switch, no such
error is given.

However the biggest problem with this is its implicit behaviour - when
I call this, it actually returns me a NULL pointer. This just caused
me an hour of hair-pulling :-(

Hopefully someone from Microsoft can verify if this is a bug or
expected behaviour.

Thanks in advance,

Re: Managed C++ potential bug: Lack of "return" statement not an error Mattias Sjögren
9/27/2003 10:49:56 PM
Brian,

[quoted text, click to view]

You'll have more luck finding the right people if you re-post to
microsoft.public.dotnet.languages.vc.



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
AddThis Social Bookmark Button