dmd -O causes incorrect output
    Saurabh Das 
    saurabh.das at gmail.com
       
    Mon Jan 25 18:07:46 UTC 2021
    
    
  
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))
         assert(false);
}
See: https://run.dlang.io/is/zlrDvy
rdmd test.d    # Runs fine
rdmd -O test.d # Assert trips
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! Please shed some light on the issue – any 
help would be greatly appreciated.
Thanks,
Saurabh
    
    
More information about the Digitalmars-d-learn
mailing list