www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21584] New: dmd -O causes incorrect output


          Issue ID: 21584
           Summary: dmd -O causes incorrect output
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: saurabh.das gmail.com

I'm seeing what appears to be a bug with the -O flag in dmd. Here is a reduced
test case:

struct SomeStruct
    long value;
bool isNumberOne(int i)
        SomeStruct l;
        if(i == 1)
                l = SomeStruct(10);
        return (l == SomeStruct(10));
void main()
    if (!isNumberOne(1))

See: https://run.dlang.io/is/zlrDvy

The assert trips when run with "rdmd -O test.d" and it does not trip when run
with "rdmd test.d". This bug is observed in all compiler versions from
dmd-2.060 through to dmd-2.095.

Forum discussion:
https://forum.dlang.org/post/dpwzsxjksoqjzjvrwehw forum.dlang.org


Jan 25 2021