Why do private member variables behaved like protected in the same module when creating deriving class?

Steven Schveighoffer schveiguy at gmail.com
Thu Nov 1 21:55:22 UTC 2018


On 11/1/18 5:08 PM, Patrick Schluter wrote:
> On Thursday, 1 November 2018 at 21:00:21 UTC, Steven Schveighoffer wrote:
>> On 11/1/18 4:47 PM, Patrick Schluter wrote:
>>> On Thursday, 1 November 2018 at 19:26:05 UTC, Steven Schveighoffer 
>>> wrote:
>>>> [...]
>>> Compiled with -m64 ? On a 32 bit machine it makes indeed no 
>>> difference as the effective calculated address is in any case modulo 
>>> 2^32-1
>>> (a + 2^32-1) % 2^32 == a-1
>>>
>>
>> amd64 system (Intel Mac)
>>
>> I wouldn't be surprised if on other architectures, you get a bus error.
>>
> the optimizer removed all the array code, in your example and only kept 
> the printf with precalculated constants. In gcc and in clang.
> 

Well, I didn't specify any optimizations, so I'm not sure that's the case.

-Steve


More information about the Digitalmars-d mailing list