Re: Null Reference
Phlip posted:
[color=blue]
> JKop wrote:
>[color=green]
>> struct Blah1
>> {
>> int& a;
>> };[/color]
>
> This won't compile. If you fix it to compile, then it might dereference a
> NULL pointer. But...[/color]
Incorrect to the former. "Wha... ?" to the latter.
[color=blue][color=green]
>> int main()
>> {
>> Blah2 poo2 = { 0 };
>>
>> Blah1 poo1( *reinterpret_ca st<Blah1 * const>(&poo2) );[/color]
>
> Undefined behavior would begin here, when you use the storage for poo2 as
> something that it is not.[/color]
I've already covered this.
[color=blue]
> The remaining code is therefor undefined; it neither does nor does not
> "dereferenc e a NULL pointer".[/color]
Here's a medal.
-JKop
Phlip posted:
[color=blue]
> JKop wrote:
>[color=green]
>> struct Blah1
>> {
>> int& a;
>> };[/color]
>
> This won't compile. If you fix it to compile, then it might dereference a
> NULL pointer. But...[/color]
Incorrect to the former. "Wha... ?" to the latter.
[color=blue][color=green]
>> int main()
>> {
>> Blah2 poo2 = { 0 };
>>
>> Blah1 poo1( *reinterpret_ca st<Blah1 * const>(&poo2) );[/color]
>
> Undefined behavior would begin here, when you use the storage for poo2 as
> something that it is not.[/color]
I've already covered this.
[color=blue]
> The remaining code is therefor undefined; it neither does nor does not
> "dereferenc e a NULL pointer".[/color]
Here's a medal.
-JKop
Comment