Why assert is in the language?
Ellery Newcomer
ellery-newcomer at utulsa.edu
Tue Jun 22 19:00:14 PDT 2010
On 06/22/2010 05:36 PM, Ali Çehreli wrote:
> Jonathan M Davis wrote:
> > Steven Schveighoffer wrote:
>
> >> all calls to assert are removed by the compiler in release mode. I
> don't
> >> think there's a way to implement that via a library (it would be nice
> >> though!)
>
> > Also IIRC, the compiler uses assert(0) to ensure that functions blow
> up at
> > runtime if you manage to hit the end of them without a return statement.
>
> I just read in TDPL that the assert(0) calls in user code are not
> removed even in release mode.
>
> Ali
Really?
// test.d
void main(){
assert(0);
}
$ dmd test -release
$ ./test
Segmentation fault (core dumped)
good job, dmd. Can anyone see if anything is going on here?
More information about the Digitalmars-d-learn
mailing list