This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

No warning about accidental cast(?)


For the following statement:

int main()
{
	int(1);
}

the compiler rightfully issues a warning "warning: statement has no effect"
However in this case:

struct X
{
    X(int _a) : a(_a) { }
    int a;
};

int main()
{
	X(1);	// author intended to write X x(1);
}

No warning is issued. I tried this with gcc-3.3.6 and gcc-4.1.0.
Is there any way to make the compiler warn about this mistake?

Regards,
Arend-Jan

P.S. If you're wondering what's the point if you're not going to use x,
I use wrapper classes and the stack unwinding mechanism to auto-release 
locks or cleanup other resources.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]