Bug 17864 – POD struct not equivalent to primitive type in comparison

Status
NEW
Severity
minor
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-09-28T10:49:26Z
Last change time
2024-12-13T18:54:43Z
Assigned to
No Owner
Creator
anonymous4
Moved to GitHub: dmd#17818 →

Comments

Comment #0 by dfj1esp02 — 2017-09-28T10:49:26Z
struct A { int a; } void g() { shared A a; A b; a=b; //converts assert(a==b); //fail } Error: incompatible types for ((a) is (b)): 'shared(A)' and 'A' Works for immutable. Is it an oversight?
Comment #1 by dunkyp — 2017-10-02T15:36:58Z
I don't think this is an oversight. The table at https://dlang.org/spec/const3.html in section 18.11 says that shared cannot be implicitly converted to mutable. The same code as yours with b marked immutable works. I do think this behaviour is a little surprising.
Comment #2 by razvan.nitu1305 — 2018-06-14T13:41:46Z
Comment #3 by robert.schadek — 2024-12-13T18:54:43Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17818 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB