Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POD struct not equivalent to primitive type in comparison #17818

Open
dlangBugzillaToGithub opened this issue Sep 28, 2017 · 2 comments
Open

Comments

@dlangBugzillaToGithub
Copy link

anonymous4 reported this on 2017-09-28T10:49:26Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=17864

CC List

  • Duncan Paterson
  • RazvanN

Description

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?
@dlangBugzillaToGithub
Copy link
Author

dunkyp commented on 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.

@dlangBugzillaToGithub
Copy link
Author

razvan.nitu1305 commented on 2018-06-14T13:41:46Z

PR: https://github.com/dlang/dmd/pull/8358

@thewilsonator thewilsonator added Review:Has PR This Issue has a PR stalled labels Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants