Issue 20086 - -betterC and "Unrestricted use of compile-time features"
Summary: -betterC and "Unrestricted use of compile-time features"
Status: RESOLVED DUPLICATE of issue 19268
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: betterC, CTFE, spec
Depends on:
Blocks:
 
Reported: 2019-07-26 20:21 UTC by mhh
Modified: 2021-10-18 16:04 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description mhh 2019-07-26 20:21:45 UTC
-------------Example----------------------------------------------------------
auto demo() //otherfile.d
{
    try {
        throw new Exception("I am become death");
    } catch(Exception e)
    {
    	return e.msg;	
    }	
}
extern(C)
void main()
{   
   import otherfile : demo;
   auto bad = demo(); //This should not compile
   enum rad = demo(); //This arguably should as per the
                      //(vague) wording of the spec
}

------------------------------------------------------------------------------

The specification implies* that arbitrary CTFE should still be possible, regardless of whether said code actually makes it into the resulting executable. 

* The term "Unrestricted* is not defined, which could make this an enhancement rather than a bug. Either way this behaviour should be possible (Across module boundaries, but in the same file raises the question of whether it should compile or not depend on whether the invalid code is actually used)
Comment 1 Mike Franklin 2019-07-26 22:36:24 UTC
> auto bad = demo(); //This should not compile

I don't see any reason that should not compile.
Comment 2 mhh 2019-07-27 00:13:05 UTC
(In reply to Mike Franklin from comment #1)
> > auto bad = demo(); //This should not compile
> 
> I don't see any reason that should not compile.

Shouldn't as in doesn't at the moment.

More philosophically, I was assuming -betterC code can't call non -betterC code e.g. It uses druntime, although I suppose in the sense that that particular exception doesn't escape the function I don't know. The spec doesn't say whether -betterC code can call code using non -betterC features.
Comment 3 Mike Franklin 2019-07-27 04:16:39 UTC
You are right.  My mistake.  It should not compile when compiling with -betterC.
Comment 4 Paul Backus 2021-10-18 16:04:20 UTC

*** This issue has been marked as a duplicate of issue 19268 ***