Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
July 15, 2017 [Issue 17654] return value incorrectly considered unique when casting to another pointer type | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17654 Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Hardware|x86_64 |All OS|Linux |All -- |
July 15, 2017 [Issue 17654] return value incorrectly considered unique when casting to another pointer type | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17654 Steven Schveighoffer <schveiguy@yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |schveiguy@yahoo.com --- Comment #1 from Steven Schveighoffer <schveiguy@yahoo.com> --- I actually think it's a design problem. assumeUTF is marked pure. The input is ubyte and the output is char. This means the compiler can reasonably assume the output is unrelated to the input and therefore unique. This is quite a pickle. We can't very well unmark it pure, and I think the compiler logic is sound. -- |
July 15, 2017 [Issue 17654] return value incorrectly considered unique when casting to another pointer type | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17654 --- Comment #2 from ag0aep6g@gmail.com --- (In reply to Steven Schveighoffer from comment #1) > I actually think it's a design problem. assumeUTF is marked pure. The input is ubyte and the output is char. This means the compiler can reasonably assume the output is unrelated to the input and therefore unique. > > This is quite a pickle. We can't very well unmark it pure, and I think the compiler logic is sound. I don't agree that the compiler logic is sound. The casts are valid. The compiler cannot assume that they don't occur. It even happens with classes (no cast needed): ---- class B { int x; } class C : B {} B toB(C c) pure { return c; } void main() { C c = new C; c.x = 1; immutable B b = toB(c); /* should be rejected */ assert(b.x == 1); /* passes */ c.x = 2; assert(b.x == 1); /* fails */ } ---- -- |
July 15, 2017 [Issue 17654] return value incorrectly considered unique when casting to another pointer type | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17654 --- Comment #3 from Steven Schveighoffer <schveiguy@yahoo.com> --- I'm not sure the UB rules for D and aliasing. In C you definitely can run into things like the array cast being considered unrelated. The class case is definitely a bug. -- |
July 15, 2017 [Issue 17654] return value incorrectly considered unique when casting to another pointer type | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17654 --- Comment #4 from ag0aep6g@gmail.com --- (In reply to Steven Schveighoffer from comment #3) > I'm not sure the UB rules for D and aliasing. In C you definitely can run into things like the array cast being considered unrelated. As far as I know, C's strict aliasing rule isn't exactly uncontroversial. Personally, I think it's an abomination. > The class case is definitely a bug. Even with the strict aliasing rule, there is a type that is allowed to alias others. In C it's char. That would be ubyte in D, I guess. The non-class examples all involve ubyte. So even with C-like strict aliasing, they should be rejected. -- |
July 15, 2017 [Issue 17654] return value incorrectly considered unique when casting to another pointer type | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17654 --- Comment #5 from Steven Schveighoffer <schveiguy@yahoo.com> --- Then the example could be changed to wchar and ushort -- |
December 17, 2022 [Issue 17654] return value incorrectly considered unique when casting to another pointer type | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17654 Iain Buclaw <ibuclaw@gdcproject.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P1 |P3 -- |
December 13 [Issue 17654] return value incorrectly considered unique when casting to another pointer type | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17654 --- Comment #6 from dlangBugzillaToGithub <robert.schadek@posteo.de> --- THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19282 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB -- |
Copyright © 1999-2021 by the D Language Foundation