The compiler does not detect an error (Message to developers)

 

The compiler does not detect the following error and compiles the code without warnings.


When I create a class like this:


class MyClass
{
public:
  void MyClass()
  {
  }
};

and then I want to instantiate it and forget to use the word "new" as follows.


MyClass *myclass = MyClass()

Compiles without problems and then there is a runtime exception.

I hope you can fix it in future versions.

Thank you!! :-)

 
karp wak:

The compiler does not detect the following error and compiles the code without warnings.


When I create a class like this:


and then I want to instantiate it and forget to use the word "new" as follows.


Compiles without problems and then there is a runtime exception.

I hope you can fix it in future versions.

Thank you!! :-)

There is nothing to fix except your code. The compiler is fine.

Eventually a warning.

 
Alain Verleyen:

There is nothing to fix except your code. The compiler is fine.

Eventually a warning.

Yes, a warning will be very helpful.
Thank you so much Alain

Reason: