D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5473 - Members of const-qualified classes are not const themselves.
Summary: Members of const-qualified classes are not const themselves.
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2011-01-21 16:05 UTC by eatingstaples
Modified: 2012-04-23 15:21 UTC (History)
2 users (show)

See Also:


Attachments
Code demonstrating the issue (271 bytes, application/octet-stream)
2011-01-21 16:05 UTC, eatingstaples
Details

Note You need to log in before you can comment on or make changes to this issue.
Description eatingstaples 2011-01-21 16:05:06 UTC
Created attachment 875 [details]
Code demonstrating the issue

An object typed as const will have const members, and a class declared as const
will have const members, but a class typed as const does not have const
members.
Comment 1 SomeDude 2012-04-22 15:28:33 UTC
The example code in attachment is:

import std.stdio;

class A
{
	int b;
}

void main()
{
	const A a = new A;
	writeln(typeof(a).stringof); // const(A)
	writeln(typeof(a.b).stringof); // const(int)
	
	writeln((const A).stringof); // const(A)
	writeln(typeof((const A).b).stringof); // int, should be const(int)
}
Comment 3 github-bugzilla 2012-04-23 14:54:31 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/94c3a15d6b267ca7ad314482813dfa74e4b55b3f
fix Issue 5473 - Members of const-qualified classes are not const themselves

https://github.com/D-Programming-Language/dmd/commit/e2c9bfa15882994a4fef9f20532797d42e887379
Merge pull request #903 from 9rnsr/fix5473

Issue 5473 - Members of const-qualified classes are not const themselves