[Issue 5799] New: Address-of operator fails on nested conditional operator expression

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Mar 30 13:46:50 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=5799

           Summary: Address-of operator fails on nested conditional
                    operator expression
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: timon.gehr at gmx.ch


--- Comment #0 from timon.gehr at gmx.ch 2011-03-30 13:43:22 PDT ---
The following (perfectly valid) D code is rejected by dmd:

int main(){
    int a;
    int *u=&(a ? a : (a ? a : a));
    return 0;
}

Error Message:
minimal.d(3): Error: incompatible types for ((&a) ? (&*(a ? &a : &a))): 'int*'
and 'int**'
minimal.d(3): Error: cannot implicitly convert expression (a ? __error :
(__error)) of type int* to int*

This is nonsense, clearly, the expression
(a ? a : (a ? a : a)) evaluates to a valid int lvalue, therefore it can have
the Address-of operator applied to it.

(For comparison: the following code compiles:
int main(){
    int a;
    (a ? a : (a ? a : a))=a;
    return 0;
})

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


More information about the Digitalmars-d-bugs mailing list