[Issue 24] GDC backend uses invalid type when using deferencing toPtr on a static array inside of a struct.
gdc-bugzilla at gdcproject.org
gdc-bugzilla at gdcproject.org
Thu Nov 1 15:32:17 PDT 2012
http://gdcproject.org/bugzilla/show_bug.cgi?id=24
--- Comment #3 from Iain Buclaw <ibuclaw at gdcproject.org> 2012-11-01 22:32:17 UTC ---
(In reply to comment #2)
> When dealing with "if (c.b)" GDC does the correct thing and throws an error.
>
> In this case b is of type char[1] and we're taking the pointer using .ptr .
> The type then becomes char*. After which we dereference it into what should be
> a 'char' a valid scalar.
>
> However, GDC returns the original type char[1]. Which is what generates the
> error shown.
>
> To help contrast this, if we remove the struct and do
>
> ===
>
> char[1] d;
>
> void main()
> {
> if (*d.ptr) return;
> return;
> }
>
> It compiles without an error even though it should be equivalent to the
> previous operation. Derefencing a pointer of static char[1].
That's because: *d.ptr
Becomes: PtrExp (SymOffExp (d))
And: *c.b.ptr
Becomes: PtrExp (AddrExp (c.b))
It is the later that suffers this bug, see PtrExp::optimize.
http://d.puremagic.com/issues/show_bug.cgi?id=8913
--
Configure issuemail: http://gdcproject.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all issue changes.
More information about the D.gnu
mailing list