proposal: should assert behave like static assert if its possible?

BCS ao at pathlink.com
Sat Jan 19 19:02:47 PST 2008


Reply to Walter,

> torhu wrote:
> 
>> dennis luehring wrote:
>> 
>>> my question for walter is:
>>> 
>>> can't assert behave like static assert if the value/condition is
>>> available compiletime
>>> 
>>> for example:
>>> 
>>> int x = byte_bit_to_int( 7, 9 ); // an static assert could do the
>>> check
>>> 
>>> int x = byte_bit_to_int( 7, random(8) ); // the normal assert is
>>> needed
>>> 
>> The problem is that sometimes you write things like assert(0), and
>> need it to trigger at runtime, not compile time.  So I think there
>> would still be a way to do that.
>> 
> You're right (it's runtime flow of control sensitive), and that's why
> it doesn't trigger at compile time.
> 

How about have a flag that spits out a list of these as warnings? For sanity's 
sake it might skip assert(false). 





More information about the Digitalmars-d mailing list