You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The __result variable is initialized at more than one location, so it doesn't conform to const (despite the guarantee it is only set once).
As such, you can't do any valid const optimizations on the decl, such as promoting it to rodata, otherwise you end up with wrong result, or segfault at runtime when calling b.str().
This you don't get with const local variables in D user code, as there can only be one initializer.
The suggested fix then, is to remove these two lines in buildResultVar.
The text was updated successfully, but these errors were encountered:
Bug: https://issues.dlang.org/show_bug.cgi?id=3390
Change set: http://www.dsource.org/projects/dmd/changeset/259
Current location in code:
dmd/compiler/src/dmd/funcsem.d
Lines 2420 to 2421 in 4661fec
In the linked changeset, the second setting of
const
looks odd, as it's against the local variable, not the out parameter.Consider for example:
The above has multiple returns, which ends up as:
The
__result
variable is initialized at more than one location, so it doesn't conform toconst
(despite the guarantee it is only set once).As such, you can't do any valid const optimizations on the decl, such as promoting it to rodata, otherwise you end up with wrong result, or segfault at runtime when calling
b.str()
.This you don't get with const local variables in D user code, as there can only be one initializer.
The suggested fix then, is to remove these two lines in
buildResultVar
.The text was updated successfully, but these errors were encountered: