Thread overview
[Issue 24] GDC backend uses invalid type when using deferencing toPtr on a static array inside of a struct.
Oct 30, 2012
Iain Buclaw
Nov 01, 2012
Daniel Green
Nov 01, 2012
Iain Buclaw
Dec 18, 2012
Iain Buclaw
Feb 03, 2013
Johannes Pfau
Mar 01, 2013
Johannes Pfau
October 30, 2012
http://gdcproject.org/bugzilla/show_bug.cgi?id=24

--- Comment #1 from Iain Buclaw <ibuclaw@gdcproject.org> 2012-10-30 13:27:56 UTC ---
This is a bug in the frontend.  It should not be generating code like this:

====
if (c.b)
{
 ....
}


Where the condition is a non-scalar type.

-- 
Configure issuemail: http://gdcproject.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all issue changes.
November 01, 2012
http://gdcproject.org/bugzilla/show_bug.cgi?id=24

--- Comment #2 from Daniel Green <venix1@gmail.com> 2012-11-01 20:23:11 UTC ---
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].

-- 
Configure issuemail: http://gdcproject.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all issue changes.
November 01, 2012
http://gdcproject.org/bugzilla/show_bug.cgi?id=24

--- Comment #3 from Iain Buclaw <ibuclaw@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.
December 18, 2012
http://gdcproject.org/bugzilla/show_bug.cgi?id=24

--- Comment #4 from Iain Buclaw <ibuclaw@gdcproject.org> 2012-12-18 13:56:23 UTC ---
https://github.com/D-Programming-Language/dmd/pull/1382

-- 
Configure issuemail: http://gdcproject.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all issue changes.
February 03, 2013
http://gdcproject.org/bugzilla/show_bug.cgi?id=24

Johannes Pfau <johannespfau@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |johannespfau@gmail.com

--- Comment #5 from Johannes Pfau <johannespfau@gmail.com> 2013-02-03 10:33:30 UTC ---
Can we close this?

-- 
Configure issuemail: http://gdcproject.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all issue changes.
March 01, 2013
http://gdcproject.org/bugzilla/show_bug.cgi?id=24

Johannes Pfau <johannespfau@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #6 from Johannes Pfau <johannespfau@gmail.com> 2013-03-01 17:23:46 UTC ---
Fixed with recent frontend merge.

-- 
Configure issuemail: http://gdcproject.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all issue changes.