CTFE bug causes null check to pass on null pointers (Issue 7602)

Don Clugston dac at nospam.com
Mon Mar 19 01:49:07 PDT 2012


On 19/03/12 06:43, H. S. Teoh wrote:
> While testing my AA implementation on existing AA-related bug, I came
> across this issue:
>
> 	http://d.puremagic.com/issues/show_bug.cgi?id=7602
>
> Upon playing around a bit with the sample code given in the bug, I
> managed to find a code snippet that would cause this code:
>
> 	if (impl !is null) { ... }
>
> to actually execute the code inside the if-statement body ***even when
> impl is null***, while running in CTFE.
>
> I've bumped the severity to critical because something is very very
> wrong with this.
>
>
> T

Yes. The existing D2 AA implementation is hopelessly broken.
You have to understand that the whole implementation of AAs in D2 is a 
HACK. It is extremely complicated and the slightest change to any code 
in the compiler or the runtime can break it. Basically CTFE has to 
reverse-engineer the druntime code in order to make it to work.
It's not an implementation issue, it's a fundamental design flaw.

I do not understand why it still part of the compiler after we agreed to 
roll back to the D1 version.



More information about the Digitalmars-d mailing list