Thread overview
[Issue 4730] New: std.c.stdlib.exit in CTFE
Jun 23, 2011
Don
Jun 23, 2011
Jacob Carlborg
August 26, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4730

           Summary: std.c.stdlib.exit in CTFE
           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 2010-08-26 06:25:39 PDT ---
This enhancement request comes from bug 4005

Currently (dmd 2.048) the following program prints:
test.d(3): Error: exit cannot be interpreted at compile time, because it has no
available source code
test.d(6): Error: cannot evaluate foo() at compile time
test.d(6): Error: static assert  (foo() == 100) is not evaluatable at compile
time


import std.c.stdlib: exit;
int foo() {
    exit(1);
    return 100;
}
static assert(foo() == 100);
void main() {}


I'd like exit() to work at compile-time too, and stop the compilation
gracefully (dmd return value is the value given to exit()).

See also bug 3952

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 23, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4730


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug@yahoo.com.au
         Resolution|                            |INVALID


--- Comment #1 from Don <clugdbug@yahoo.com.au> 2011-06-23 00:52:15 PDT ---
Implementing a complicated corner case for an obscure and dangerous feature
would
need a extremely powerful rationale.
Marking as INVALID rather WONTFIX, because the bug report doesn't have any use
case at all.

To give an idea of the complexity: consider what would happen if it were called speculatively, eg in a template constraint.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 23, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4730


Jacob Carlborg <doob@me.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |doob@me.com


--- Comment #2 from Jacob Carlborg <doob@me.com> 2011-06-23 02:09:29 PDT ---
Isn't this exactly what static assert is for?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 24, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4730



--- Comment #3 from bearophile_hugs@eml.cc 2011-06-24 16:26:25 PDT ---
(In reply to comment #1)

I don't reopen this enhancement request because I trust your judgement, but here are some answers:

> Marking as INVALID rather WONTFIX, because the bug report doesn't have any use case at all.

Sometimes to debug normal run-time code I add a printf() followed by an exit()
becuse I don't need the computation to continue after the debug print. The
compile-time exit was meant to be used like that, with the compile-time string
print of bug 3952 (that doesn't print a newline after the string).


> consider what would happen if it were called speculatively, eg in a template constraint.

It's an exit(), so it has to stops the whole compiler and the whole compilation
stack.

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