[Issue 6205] Strongly-pure nothrow functions with ignored return value are entirely stripped even if it contains a failing 'assert'.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jun 24 01:34:09 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6205


Jonathan M Davis <jmdavisProg at gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg at gmx.com


--- Comment #1 from Jonathan M Davis <jmdavisProg at gmx.com> 2011-06-24 01:29:19 PDT ---
I'm not sure that this is a bug. It's a strongly pure function. It _is_
nothrow, which means that it won't throw any Exception, and its return value
isn't used. assert is more of a debugging tool than anything. Sure,
assert(false) sticks around in release mode, but still. Based on the purity and
nothrow rules, this function can be optimized out of existance. I really don't
see a problem with this. Now, assuming that is indeed the correct behavior, the
obviously runnable/test41.d needs to be fixed, but it looks to me like having
the call to x optimized out of existance makes perfect sense. And if the assert
doesn't get hit, then it doesn't get hit. Asserts are intended primarily for
debugging purposes. Yes, it's an assert(false) and not a normal assert, but
still, if we start worrying about whether an assert would have killed a
function or not, then we won't be able to optimize out functions like this,
which wouldn't be good IMHO. Now, assuming that it's really only an issue when
you have a strongly pure function where you throw away its return value, then
maybe that's not a big deal, because that's bad code on the part of the
programmer anyway, but I'm still inclined to think that it makes sense for x to
never be called in this code (at least if optimizations are turned on).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list