No warning about accidental cast(?)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux