Fix Issue 18493 - [betterC] Can't use aggregated type with postblit (+More)#8253
Fix Issue 18493 - [betterC] Can't use aggregated type with postblit (+More)#8253JinShil wants to merge 1 commit intodlang:masterfrom JinShil:betterC_nothrow
Conversation
|
Thanks for your pull request, @JinShil! Bugzilla references
|
|
Requiring |
Adding a @andralex and @WalterBright, it would be very helpful if you two could come to some agreement on this. |
|
In order for this to work we need to agree that the feature set of D available to -betterC builds at compile-time is identical to the feature set of D available to -betterC at runtime. Users of -betterC can currently employ features of D at compile-time that are not available in the -betterC subset of the language at runtime. An obvious example is If we can agree that -betterC at compile time and -betterC at runtime must have feature parity, then we can move forward with this PR. Until then, this is blocked. |
|
current betterC not allow compile time call function with GC, this is reduce the power of betterC. (some template will only use to generate static const will not work, like web view template compile) |
|
Yeah, basically the only way to allocate in a CTFE function is to use the GC. If that's not allowed in betterC then we're going to severely limit CTFE for betterC. I don't see why you wouldn't want be able to take full advantage of Phobos during CTFE. There was a talk about someone that was parsing a PDF file with CTFE to extract op codes or similar for some kind of architecture. This generated some code which would always be up to date with the specification. Good luck doing that without Phobos. |
|
CTFE BetterC with GC make betterC useless. |
|
Why useless? Do you mean betterC is useless without GC in CTFE? |
|
At compile time I want to be able to do what I normally can, but when I compile with betterC I can't. There really should not be any reason for that behaviour. |
|
If |
It's so bad you can't even use things like tuple. This makes ctfe completely useless in betterC mode. |
|
On windows exception mechanism is provided by the system, and invalid memory access is reported as an exception. If it's C, it doesn't mean there are no exceptions. |
|
not being able to use string concat at compile time would be completely useless. |
Overview
Issue 18493 revealed an oversight in the implementation of betterC: -betterC does not support throwing exceptions, but does not require a
nothrowenvironment. #8184 provided a fix to the auto-generated try-catches implicitly added to an aggregate's field postblits, but the fundamental issue remains. This PR attempts to fix that fundamental issue.I discussed this with @andralex and @WalterBright privately in an e-mail exchange:
nothrowenvironment?I've chosen to side with @andralex for this PR as I agree with the principle that:
That is, when compiling in -betterC, or with a minimal runtime that does not support
Throwable, the compiler will require all functions to be attributed withnothrow(which users should already be doing anyway).Breaking Changes
This will break existing -betterC code for sure, but I think that's OK:
nothrow:attribution to the top of the module. Users should already be doing this anyway when compiling without support for exceptions.DRuntime Changes
To make this work druntime's object.d also needed to be modified (See dlang/druntime#2184). This is because, despite the fact the -betterC does not link with druntime or phobos, it still imports object.d. There is a large amount of code in object.d that not utilized when compiling with -betterC, but it is not
versioned out like it should be, and that causes compiler errors with the changes in this PR. The druntime PR will also enable other planned features for -betterC including using classes withstatic memebers, so it is also forward-looking.Adding the "Vision" label as this is congruent with item 4 of Vision 2018H1