[Issue 14696] destructor for temporary called before statement is complete with conditional operator
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Thu Nov 28 14:15:45 UTC 2019
    
    
  
https://issues.dlang.org/show_bug.cgi?id=14696
Suleyman Sahmi (سليمان السهمي) <sahmi.soulaimane at gmail.com> changed:
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |sahmi.soulaimane at gmail.com
         Resolution|FIXED                       |---
--- Comment #12 from Suleyman Sahmi (سليمان السهمي) <sahmi.soulaimane at gmail.com> ---
The following case is still affected:
```
extern(C) void puts(const char*);
struct S
{
    int i;
    ~this() { puts("D"); }
}
S makeS(int i) { return S(i); }
void main()
{
    int var = true ? 1 : makeS(makeS(1).i - 1).i;
}
```
The program prints "D" at runtime which means the destructor is called when it
shouldn't.
--
    
    
More information about the Digitalmars-d-bugs
mailing list