public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug d/96153] New: d: struct literals have non-deterministic hash values
@ 2020-07-10 14:40 ibuclaw at gdcproject dot org
  2020-08-04 15:05 ` [Bug d/96153] " cvs-commit at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: ibuclaw at gdcproject dot org @ 2020-07-10 14:40 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96153
           Summary: d: struct literals have non-deterministic hash values
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: d
          Assignee: ibuclaw at gdcproject dot org
          Reporter: ibuclaw at gdcproject dot org
  Target Milestone: ---

struct Checked(T, Hook)
{
    private T payload;
    Hook hook;

    size_t toHash() const nothrow @safe
    {
        return hashOf(payload) ^ hashOf(hook);
    }
}

Checked!(T, Hook) checked(Hook, T)(const T value)
{
    return Checked!(T, Hook)(value);
}

@system unittest
{
    static struct Hook3
    {
        ulong var1 = ulong.max;
        uint var2 = uint.max;
    }

    assert(checked!Hook3(12).toHash() != checked!Hook3(13).toHash());
    assert(checked!Hook3(13).toHash() == checked!Hook3(13).toHash());
}

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

end of thread, other threads:[~2020-08-26  8:05 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-10 14:40 [Bug d/96153] New: d: struct literals have non-deterministic hash values ibuclaw at gdcproject dot org
2020-08-04 15:05 ` [Bug d/96153] " cvs-commit at gcc dot gnu.org
2020-08-05  8:46 ` ro at gcc dot gnu.org
2020-08-05 11:42 ` ibuclaw at gdcproject dot org
2020-08-05 16:30 ` ibuclaw at gdcproject dot org
2020-08-06 12:49 ` ibuclaw at gdcproject dot org
2020-08-23  7:05 ` ibuclaw at gdcproject dot org
2020-08-24 19:49 ` ibuclaw at gdcproject dot org
2020-08-26  8:04 ` cvs-commit at gcc dot gnu.org
2020-08-26  8:05 ` 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).