public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug d/96435] New: d: Returning boolean in a union violates @safe code
@ 2020-08-03 15:49 ibuclaw at gdcproject dot org
  2021-07-29 15:12 ` [Bug d/96435] " cvs-commit at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: ibuclaw at gdcproject dot org @ 2020-08-03 15:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96435

            Bug ID: 96435
           Summary: d: Returning boolean in a union violates @safe code
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: d
          Assignee: ibuclaw at gdcproject dot org
          Reporter: ibuclaw at gdcproject dot org
  Target Milestone: ---

In this test, the return value is both true and false at the same time.
---
bool schrodingersCat() @safe {
        union Box { bool b; int state; }
        Box u;
        u.state = 42;
        return u.b;
}
void main() @safe {
        import std.stdio;
        bool b = schrodingersCat();
        if (b) writeln("alive");
        if (!b) writeln("dead");
}

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-07-29 15:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-03 15:49 [Bug d/96435] New: d: Returning boolean in a union violates @safe code ibuclaw at gdcproject dot org
2021-07-29 15:12 ` [Bug d/96435] " cvs-commit at gcc dot gnu.org
2021-07-29 15:20 ` cvs-commit at gcc dot gnu.org
2021-07-29 15:21 ` cvs-commit at gcc dot gnu.org
2021-07-29 15:22 ` cvs-commit at gcc dot gnu.org
2021-07-29 15:27 ` ibuclaw at gdcproject dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).