public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "doko at debian dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/98731] New: s390x: Large classes of std::bitset and std::vector<bool> hash the same Date: Mon, 18 Jan 2021 14:41:46 +0000 [thread overview] Message-ID: <bug-98731-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98731 Bug ID: 98731 Summary: s390x: Large classes of std::bitset and std::vector<bool> hash the same Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: doko at debian dot org Target Milestone: --- [forwarded from https://bugs.debian.org/977638] same behavior with GCC 8, 9 and 10. On s390x, std::hash returns identical values for large classes of std::bitset and std::vector<bool>: $ cat bug.cc #include <bitset> #include <functional> #include <iostream> #include <vector> int main() { std::bitset<2> a("00"), b("01"); std::vector<bool> c = {false, true, false, true}; std::vector<bool> d = {true, false, true, false}; std::bitset<9> e("000000000"), f("010101010"); std::vector<bool> g = {true, true, true, true, true, true, true, true, true}; std::vector<bool> h = {false, false, false, true, true, false, false, false, false}; std::hash<std::bitset<2>> h1; std::hash<std::bitset<9>> h2; std::hash<std::vector<bool>> h3; std::cout << h1(a) << '\n' << h1(b) << '\n' << h3(c) << '\n' << h3(d) << "\n\n" << h2(e) << '\n' << h2(f) << '\n' << h3(g) << '\n' << h3(h) << '\n'; } $ g++ -o bug bug.cc $ ./bug 7857072875483051545 7857072875483051545 7857072875483051545 7857072875483051545 4158372090644325695 4158372090644325695 4158372090644325695 4158372090644325695 It appears that the hash value is completely dependent on the size of the object in bytes. 1–8-bit values all hash to 7857072875483051545; 9–16-bit values all hash to 4158372090644325695; and though bug.cc doesn’t demonstrate it, 17-bit values hash to 14756137038141193723.
next reply other threads:[~2021-01-18 14:41 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-01-18 14:41 doko at debian dot org [this message] 2021-01-19 7:43 ` [Bug libstdc++/98731] " rguenth at gcc dot gnu.org 2021-01-19 10:00 ` redi at gcc dot gnu.org 2021-01-19 18:02 ` redi at gcc dot gnu.org 2021-01-21 11:35 ` redi at gcc dot gnu.org 2021-04-19 10:40 ` redi at gcc dot gnu.org 2021-09-29 18:15 ` redi at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-98731-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).