public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "josephttilahun at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/92798] -fshort-enums can break iterators of std::map Date: Thu, 05 Oct 2023 17:43:12 +0000 [thread overview] Message-ID: <bug-92798-4-xdawKdNJD2@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-92798-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92798 Joseph Tilahun <josephttilahun at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |josephttilahun at gmail dot com --- Comment #4 from Joseph Tilahun <josephttilahun at gmail dot com> --- I encountered this same bug when using -fshort-enums with std::map iterators. The fact that -fshort-enums breaks std::map iterators implies that there's an enum somewhere without an explicit underlying type. In /usr/include/c++/9/bits/stl_tree.h, there's an enum that enumerates the possible colors of a node of a red-black tree: enum _Rb_tree_color { _S_red = false, _S_black = true }; struct _Rb_tree_node_base { typedef _Rb_tree_node_base* _Base_ptr; typedef const _Rb_tree_node_base* _Const_Base_ptr; _Rb_tree_color _M_color; _Base_ptr _M_parent; _Base_ptr _M_left; _Base_ptr _M_right; // Other code that's not relevant } The _Rb_tree_color enum does not have an explicit underlying type. I tried modifying this to: enum _Rb_tree_color : int { _S_red = false, _S_black = true }; struct _Rb_tree_node_base { typedef _Rb_tree_node_base* _Base_ptr; typedef const _Rb_tree_node_base* _Const_Base_ptr; _Rb_tree_color _M_color; _Base_ptr _M_parent; _Base_ptr _M_left; _Base_ptr _M_right; // Other code that's not relevant } and -fshort-enums does not break this. I also tried modifying this to: enum _Rb_tree_color { _S_red = false, _S_black = true }; struct _Rb_tree_node_base { typedef _Rb_tree_node_base* _Base_ptr; typedef const _Rb_tree_node_base* _Const_Base_ptr; int _M_color; _Base_ptr _M_parent; _Base_ptr _M_left; _Base_ptr _M_right; // Other code that's not relevant } and -fshort-enums does not break this. It seems to me that the _Rb_tree_color enum is the real problem. -fshort-enums simply exposes the fact that the _Rb_tree_color enum does not have an explicit underlying type. Is there a reason why the _Rb_tree_color enum does not have an explicit underlying type?
next parent reply other threads:[~2023-10-05 17:43 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-92798-4@http.gcc.gnu.org/bugzilla/> 2023-10-05 17:43 ` josephttilahun at gmail dot com [this message] 2023-10-05 17:48 ` pinskia at gcc dot gnu.org 2023-10-07 11:44 ` 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-92798-4-xdawKdNJD2@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).