Bug 20086 – -betterC and "Unrestricted use of compile-time features"
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-07-26T20:21:45Z
Last change time
2021-10-18T16:04:20Z
Keywords
betterC, CTFE, spec
Assigned to
No Owner
Creator
mhh
Comments
Comment #0 by maxhaton — 2019-07-26T20:21:45Z
-------------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 by slavo5150 — 2019-07-26T22:36:24Z
> auto bad = demo(); //This should not compile
I don't see any reason that should not compile.
Comment #2 by maxhaton — 2019-07-27T00:13:05Z
(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 by slavo5150 — 2019-07-27T04:16:39Z
You are right. My mistake. It should not compile when compiling with -betterC.
Comment #4 by snarwin+bugzilla — 2021-10-18T16:04:20Z
*** This issue has been marked as a duplicate of issue 19268 ***