473,387 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Potential Managed C++ bug - missing return statement allowed

Hi all,

The following code unfortunately compiles fine with VC++ 7.1 and the
/clr switch:

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

Rather than throw a syntax error of "foo() must return a value", it
instead compiles fine and has the less-than-desirable implicit
behaviour of returning a null Type*. If you remove the "throw"
statement, the syntax error is caught by the compiler.

Can anyone confirm or deny? If this is a known bug already, is there a
planned fix date?

Thanks in advance!

Best regards,
Brian
Nov 16 '05 #1
1 938
Hmmm, I created a Managed C++ console app and this code below :-

__gc class Test
{
public:
System::Type* foo()
{
if (0)
{
throw 1;
}
}

};

gave me :-

c:\.....cpp(19): error C2561: 'Test::foo' : function must return a value

I used VC++ 7.1 too!

--
Regards,
Nish [VC++ MVP]

"Brian Kelly" <br******@hotmail.com> wrote in message
news:8c*************************@posting.google.co m...
Hi all,

The following code unfortunately compiles fine with VC++ 7.1 and the
/clr switch:

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

Rather than throw a syntax error of "foo() must return a value", it
instead compiles fine and has the less-than-desirable implicit
behaviour of returning a null Type*. If you remove the "throw"
statement, the syntax error is caught by the compiler.

Can anyone confirm or deny? If this is a known bug already, is there a
planned fix date?

Thanks in advance!

Best regards,
Brian

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Lars Grøtteland | last post by:
Hello! Could anyone help me please. I tried the following - I created an application in .NET 2003. The project is a MFC Application a CDialog. I ran the application fine. I changed the...
1
by: lolomgwtf | last post by:
I have a managed C++ method that wraps unmanaged code and creates a managed object holding data retrieved form an unmanged one. I want create an instance of this managed class in C#, pass it to...
16
by: Ekim | last post by:
hello, I'm allocating a byte-Array in C# with byte byteArray = new byte; Now I want to pass this byte-Array to a managed C++-function by reference, so that I'm able to change the content of the...
0
by: Scott Chang | last post by:
Hi all, I tried to use Managed C++ coding of VC++.NET (2002)and OpenGL version 1.2 to draw a hexagon shape of benzene. My OpenGLdrawBenzene.cpp is the following: // This is the main project file...
6
by: Jon | last post by:
Is auto_ptr allowed in managed C++ class? I have my doubts because of the following example: #include "stdafx.h" #include <iostream> #include <memory> using namespace std; #using...
2
by: Hans Wien | last post by:
I have to write a lot of data to excel for analysts who use it further from there but would like to use managed C++ and not C# since a lot of code is involved which already exists now in managed...
2
by: inventor | last post by:
I'm doing programming for my science prodject, and when I was programming (I'm building an alphebatizer) I ran into this bug: I've got an input box, but no button or output box. so I do some...
1
by: mschuck | last post by:
Here is the scenario I'm trying to make work. I've got 2 managed C++ classes, each of which wrappes an unmanaged C++ class, kind of like so: __nogc class UnmanagedClassA { public: void...
5
by: raylopez99 | last post by:
I need an example of a managed overloaded assignment operator for a reference class, so I can equate two classes A1 and A2, say called ARefClass, in this manner: A1=A2;. For some strange reason...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.