Warning on dangerous use of assert() ?

Dave Korn dk@artimi.com
Wed Mar 17 12:43:00 GMT 2004


 

> -----Original Message-----
> From: gcc-owner On Behalf Of hartmut.schirmer
> Sent: 17 March 2004 12:29

> Hi,
> 
> does it make sense to add a warning to GCC to avoid cases 
> where the condition of an assert() has side effect ?
> 
> I just found code like this
> 
>   assert(init_something());
> 
> failing in release mode ...
> 
> Thanks,
> Hartmut


  Sounds like an absolutely excellent idea to me; it's entirely in line with
warnings about assignments in if conditionals and so on.  People quite often
forget that asserts disappear in release builds.


    cheers, 
      DaveK
-- 
Can't think of a witty .sigline today....
 






More information about the Gcc mailing list