Issue 4251 - Hole in the const system: immutable(T)[] implicitly casts to ref const(T)[] #558

Merged
merged 5 commits into from Jan 16, 2012

Conversation

Projects
None yet
4 participants
Member

9rnsr commented Dec 13, 2011

http://d.puremagic.com/issues/show_bug.cgi?id=4251
This pull request requires #425 doe to prevent druntime breaking.

(@yebblies had posted #115, but it was a bit complicated than I had thought.)

When implicitly converting types with indirections, we consider only tail part of the types.
e.g. The tail part of T*** is T**.
There are two rules:

  • If the tail of destination type is full const of the tail of source type, it is const convertible.
  • Otherwise the tails of source and destination should be same.

e.g.

T*** => const(T***) OK, dst tail is full const of src tail
T*** => const(T**)* OK, dst tail is full const of src tail
T*** => const(T*)** NG, dst tail is differnt from src tail
T*** => const(T)*** NG, dst tail is differnt from src tail
T*** => T*** OK, dst tail is same as src tail
immutable(T*)** => const(T*)** NG, dst tail is differnt from src tail

Additional fix:
Issue 5493 - Able to overwrite immutable data by passing through ref function parameter

Member

yebblies commented Dec 13, 2011

This is great. My pull 115 was a terrible solution, aside from being wrong.
Does this fix bug 5493 as well?

Member

9rnsr commented Dec 13, 2011

Yes. I'm editing above summary, and now commits are divided for 4251 and 5493.

Member

9rnsr commented Dec 15, 2011

Added fix for 5493 + inout bug.
It is specified in digitalmars.D newsgroup by Steven Schveighoffer.

Owner

braddr commented Jan 2, 2012

Fails the dmd func lit test on all platforms. One example:
http://d.puremagic.com/test-results/pull.ghtml?runid=15013
../src/dmd -m32 -Irunnable -odtest_results/runnable -oftest_results/runnable/funclit_0 runnable/funclit.d
Segmentation fault

Member

9rnsr commented Jan 2, 2012

This fail requires #593.

Member

9rnsr commented Jan 3, 2012

Add test for "Issue 7202 - Hole in type system still present for delegates".

WalterBright added a commit that referenced this pull request Jan 16, 2012

Merge pull request #558 from 9rnsr/fix4251
Issue 4251 - Hole in the const system: immutable(T)[] implicitly casts to ref const(T)[]

@WalterBright WalterBright merged commit 47ad405 into dlang:master Jan 16, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment