www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 869] New: Cast of a parenthesized expression combined with !is is mistaken for a C style cast and a template specialization

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

           Summary: Cast of a parenthesized expression combined with !is is
                    mistaken for a C style cast and a template
                    specialization
           Product: D
           Version: 1.00
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: minor
          Priority: P3
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: deewiant gmail.com


static assert (cast(int)(foo) !is null);
// or with normal assert:
void main() { assert (cast(int)(foo) !is null); }

The above code snippet produces, for both lines 1 and 3, the following pair of
errors:

(type identifier : specialization) expected following is
C style cast illegal, use cast(foo)!0

It's easy to work around: either remove the parentheses around foo or add
another pair of them, whichever is appropriate for the expression.


-- 
Jan 21 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=869


thomas-dloop kuehne.cn changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |spec




------- Comment #1 from thomas-dloop kuehne.cn  2007-01-23 07:46 -------
http://www.digitalmars.com/d/overview.html
D retains C operators and their precedence rules, order of evaluation rules, 

As C hasn't got an "!is" operator it is impossible to decide how this code should be interpreted: # # cast(int)(foo !is null) // 1 # (cast(int)foo) !is null // 2 # --
Jan 23 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=869


Christian Kamm <kamm-removethis incasoftware.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                 CC|                            |kamm-removethis incasoftwar
                   |                            |e.de




--- Comment #2 from Christian Kamm <kamm-removethis incasoftware.de> 
2009-06-30 10:33:34 PDT ---
DMD 1.045 digests the following test case without complaint:

class C {}
C foo;
void main() {
  assert (cast(Object)(foo) !is null);
}

To resolve this issue, add the following line to "Identity Expressions":

The is and !is expressions have the same precedence as the equality expressions
== and !=.

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


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug yahoo.com.au
         Resolution|                            |FIXED


--- Comment #3 from Don <clugdbug yahoo.com.au> 2009-12-15 14:22:17 PST ---
This was fixed between 1.030 and 1.036.
No spec change is required (precedence is implied in the BNF descriptions).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 15 2009