Re: No warning about accidental cast(?)

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

 



On 12/06/07, Arend-Jan Wijtzes <ajwytzes@xxxxxxxxxxxx> wrote:
However in this case:

[...]

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?

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.

I think you've probably found your own answer.  Constructors and
destructors can have arbitrary side effects, so GCC might just not
try.  The inliner might be able to reduce it to something that it
could figure out, but by then the variable information might be lost
(I don't know enough about internals to know).

And if you're using RAII classes for things like scoped locks, they
certainly have side effects, so the statement does have an effect.
For anything without side effects, you'll need to use it at some
point, where you'll get an undeclared identifier warning.

~ Scott

P.S. I think that's construction of a temporary, not a cast, technically.

[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