Thread overview | ||||||
---|---|---|---|---|---|---|
|
January 29, 2014 [Issue 12028] New: Disallow side effects in asserts | ||||
---|---|---|---|---|
| ||||
https://d.puremagic.com/issues/show_bug.cgi?id=12028 Summary: Disallow side effects in asserts Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: bearophile_hugs@eml.cc --- Comment #0 from bearophile_hugs@eml.cc 2014-01-29 08:25:00 PST --- I suggest to statically disallow code like this, that is to disallow side effects in assert(), that are source of bugs (because the code can act differently in release mode): int foo(ref int y) pure nothrow { return y++; } void main() { int x; assert(++x); assert(foo(x)); } -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 30, 2014 [Issue 12028] Disallow side effects in asserts | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | https://d.puremagic.com/issues/show_bug.cgi?id=12028 Andrej Mitrovic <andrej.mitrovich@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich@gmail.com --- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2014-01-30 01:49:47 PST --- It might be controversial, however I do remember someone actually running into this bug in #d last year. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 03, 2014 [Issue 12028] Disallow side effects in asserts | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | https://d.puremagic.com/issues/show_bug.cgi?id=12028 Dylan Knutson <tcdknutson@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tcdknutson@gmail.com --- Comment #2 from Dylan Knutson <tcdknutson@gmail.com> 2014-02-03 14:01:09 PST --- Andrej, I believe that was me! It would have been nice to have that code checked for side effects in assert statements. I'm in support of this enhancement request. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 03, 2014 [Issue 12028] Disallow side effects in asserts | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | https://d.puremagic.com/issues/show_bug.cgi?id=12028 --- Comment #3 from bearophile_hugs@eml.cc 2014-02-03 14:33:11 PST --- A discussion thread: http://forum.dlang.org/thread/yzopesnnlgidhelsrrci@forum.dlang.org A problem raised by Brad Roberts: > I have one semi-large code base where I validate the locking semantics by adding assert(!lock.try_acquire)'s. That's clearly a side effect, but also clearly should never have one if the code is correct. And an answer by Marco Leise: > Basically lock.try_acquire is pure when it returns false, and if not, the program is terminated anyways so it doesn't make a difference. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation