[Issue 10854] debug should also bypass safety and nothrow

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Aug 19 09:21:48 PDT 2013


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


bearophile_hugs at eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs at eml.cc


--- Comment #1 from bearophile_hugs at eml.cc 2013-08-19 09:21:47 PDT ---
(In reply to comment #0)

> debug instructions/blocks were allowed to nicely bypass function purity. This
> allows inserting impure calls for testing reasons inside pure functions.
> 
> This should be expanded for @safe and nothrow. Its really a natural evolution
> IMO.

If in module A you call a nothrow function F from module B, and you pre-compile
module A with aggressive optimizations that rely on F never throwing, and then
you run the module B in debug mode and now the function F throws, what does it
happens?

If F is also tagged with 'pure' and when you debug B you call something not
pure, like printf(), inside the debug{}, the optimizations of the compilation
of the module A could cause some of those calls to printf() to never happen.
But if the code inside debug{} is well behaved this doesn't cause significant
problems. Peraphs with nothrow the situation is worse.


> There is nothing more annoying than inserting a test "writeln()" in a function,
> only to be refused because said function is @safe or nothrow.

For that I try to use printf(), that is nothrow.

-- 
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