digitalmars.D.bugs - [Issue 14534] New: Front-end should lower all non-scalar condition
- via Digitalmars-d-bugs (34/34) Apr 30 2015 https://issues.dlang.org/show_bug.cgi?id=14534
https://issues.dlang.org/show_bug.cgi?id=14534 Issue ID: 14534 Summary: Front-end should lower all non-scalar condition expressions Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: DMD Assignee: nobody puremagic.com Reporter: ibuclaw gdcproject.org Types in D2 that have a non-scalar representation, this involves: - Dynamic arrays { size_t length, void *ptr } - Delegates { void *object, void *funcptr } - Associative arrays { void *ptr } Are silently allowed to pass through the front-end in checkToBoolean checks as valid boolean values. This means that type-strict backends (GDC, LDC) must do it's own special lowering to ensure that the correct value is extracted and proper scalar -> bool conversion is done. This also means that dmd, gdc, and ldc may be each doing something different when it comes to the following operations. --- if (arr) { ... } // Could be (arr.ptr != null) or (arr.ptr || arr.length) if (dg) { ... } // Could be (dg.funcptr != null) or (dg.object || dg.funcptr) if (aa) { ... } // arr.ptr != null --- So I propose that the front-end should instead do this lowering so the behaviour is 'precisely defined' and not up for interpretation of the backend implementer. --
Apr 30 2015