Bug 18209 – std.uni.byGrapheme is not usable in CTFE

Status
NEW
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-01-08T15:05:55Z
Last change time
2024-12-01T16:31:52Z
Keywords
CTFE
Assigned to
No Owner
Creator
basile-z
Moved to GitHub: phobos#10289 →

Comments

Comment #0 by b2.temp — 2018-01-08T15:05:55Z
test case: ``` import std.uni : byGrapheme; import std.range.primitives : walkLength; enum a = "a".byGrapheme.walkLength; void main(){} ``` std/uni.d(7631,16): Error: reinterpretation through overlapped field slen_ is not allowed in CTFE
Comment #1 by jack — 2018-01-08T15:20:57Z
Pretty sure there's a way to change a struct's layout if it's being used in compile time. All that needs to be done is just bring the fields out of the union when used in CTFE.
Comment #2 by jack — 2018-01-09T14:00:02Z
(In reply to Jack Stouffer from comment #1) > Pretty sure there's a way to change a struct's layout if it's being used in > compile time. All that needs to be done is just bring the fields out of the > union when used in CTFE. Apparently this isn't possible. There are two ways of fixing this 1. remove the small string optimization from Grapheme 2. have byGrapheme return a specialized type of Grapheme that doesn't have SSO
Comment #3 by jack — 2018-01-09T14:01:45Z
(In reply to Jack Stouffer from comment #2) > Apparently this isn't possible. > > There are two ways of fixing this > > 1. remove the small string optimization from Grapheme > 2. have byGrapheme return a specialized type of Grapheme that doesn't have > SSO Or 3. Create a special function byGraphemeCTFE which is a range of CTFEGraphemes. That way there's no performance regression
Comment #4 by robert.schadek — 2024-12-01T16:31:52Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10289 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB