Re: immutable T.init, and pointers to mutable data

2014-09-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/25/14 10:56 AM, monarch_dodra wrote: On Thursday, 25 September 2014 at 13:37:52 UTC, Steven Schveighoffer wrote: But clearly, any code that results in an immutable pointer to mutable data without casts is incorrect. We should start by outlawing such code, and if there are ways we can carv

Re: immutable T.init, and pointers to mutable data

2014-09-25 Thread monarch_dodra via Digitalmars-d-learn
On Thursday, 25 September 2014 at 13:37:52 UTC, Steven Schveighoffer wrote: On 9/25/14 9:00 AM, monarch_dodra wrote: On Thursday, 25 September 2014 at 12:46:01 UTC, Steven Schveighoffer wrote: On 9/25/14 5:47 AM, monarch_dodra wrote: I was playing around with how T.init works. And I think I ma

Re: immutable T.init, and pointers to mutable data

2014-09-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/25/14 9:00 AM, monarch_dodra wrote: On Thursday, 25 September 2014 at 12:46:01 UTC, Steven Schveighoffer wrote: On 9/25/14 5:47 AM, monarch_dodra wrote: I was playing around with how T.init works. And I think I may have found a type loophole. Given that you may initialize a pointer member

Re: immutable T.init, and pointers to mutable data

2014-09-25 Thread monarch_dodra via Digitalmars-d-learn
On Thursday, 25 September 2014 at 12:46:01 UTC, Steven Schveighoffer wrote: On 9/25/14 5:47 AM, monarch_dodra wrote: I was playing around with how T.init works. And I think I may have found a type loophole. Given that you may initialize a pointer member to the address to a static global: //

Re: immutable T.init, and pointers to mutable data

2014-09-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/25/14 5:47 AM, monarch_dodra wrote: I was playing around with how T.init works. And I think I may have found a type loophole. Given that you may initialize a pointer member to the address to a static global: // __gshared int a = 0; struct S { int* p = &a; } // Then, in theory