assume, assert, enforce, @safe

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 31 12:54:10 PDT 2014


On Thu, Jul 31, 2014 at 07:39:54PM +0000, Jonathan M Davis via Digitalmars-d wrote:
> On Thursday, 31 July 2014 at 19:36:34 UTC, H. S. Teoh via Digitalmars-d
> wrote:
> >On Thu, Jul 31, 2014 at 03:43:48PM -0300, Ary Borenszweig via
> >Digitalmars-d wrote:
[...]
> >>>>What do you suggest to use to check program bugs?
> >>>
> >>>assert()
> >>
> >>Then you are potentially releasing programs with bugs that are of
> >>undefined behavior, instead of halting the program immediately.
> >
> >Isn't that already what you're doing with the current behaviour of
> >assert? Not only in D, but also in C/C++.
> 
> Yes, but I think that his point was that he wants a way to check
> programming bugs in release mode, and Walter was saying not to use
> enforce for checking programming bugs. So, that leaves the question of
> how to check them in release mode, since assertions won't work in
> release mode. But the answer to that is normally to not compile in
> release mode. And I believe that dmd gives enough control over that
> that you can get everything that -release does without disabling
> assertions using flags other than -release.
[...]

Ah, I see.

But doesn't that just mean that you shouldn't use -release, period?
AFAIK, the only thing -release does it to remove various safety checks,
like array bounds checks, asserts, contracts (which are generally
written using asserts), etc.. I'd think that Ary wouldn't want any of
these disabled, so he shouldn't use -release at all. There's already -O
and -inline to enable what people generally expect from a release build,
so -release wouldn't really be needed at all.

Right?


T

-- 
Some ideas are so stupid that only intellectuals could believe them. -- George Orwell


More information about the Digitalmars-d mailing list