D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 17864 - POD struct not equivalent to primitive type in comparison
Summary: POD struct not equivalent to primitive type in comparison
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P3 minor
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-28 10:49 UTC by anonymous4
Modified: 2024-12-13 18:54 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description anonymous4 2017-09-28 10:49:26 UTC
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 Duncan Paterson 2017-10-02 15:36:58 UTC
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 RazvanN 2018-06-14 13:41:46 UTC
PR: https://github.com/dlang/dmd/pull/8358
Comment 3 dlangBugzillaToGithub 2024-12-13 18:54:43 UTC
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