www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8913] New: Wrong code in IfStatement condition Expression

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8913

           Summary: Wrong code in IfStatement condition Expression
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: ibuclaw ubuntu.com



struct A {
  char[1] b;
}

void main()
{
  A c;
  if (*c.b.ptr)
    return;
  return;
}

The following of type char
====
*c.b.ptr
====

Generates and sends to the backend as type char[1]
====
c.b
====


This is wrong and invalid (non-scalar types cannot be used as boolean types).


Regards
Iain.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 30 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8913




This conversion occurs in PtrExp::optimize.

*&c.b  ->  c.b



For static array types, would there be a problem doing this instead?

*&c.b  ->  c.b[0]

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 30 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8913


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull



https://github.com/D-Programming-Language/dmd/pull/1382

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 18 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8913




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/57f6bdcc3ec10dfc9f7081e7b781d4799e45317f
fix Issue 8913 - Wrong code in IfStatement condition Expression

Type cast from `e : T[n]` to `T*` should generate `&e[0]`, not `&e`.

https://github.com/D-Programming-Language/dmd/commit/62818b3863a14ccc828c1d3623db038170a8c129


Issue 8913 - Wrong code in IfStatement condition Expression

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 31 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8913


Kenji Hara <k.hara.pg gmail.com> changed:

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


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 31 2013