From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 24F093858C52; Thu, 5 Oct 2023 17:43:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 24F093858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1696527794; bh=Ct0ns7yG9EpCSnR4wCxoQb/dRnFiAiycUzeX0Wa6270=; h=From:To:Subject:Date:In-Reply-To:References:From; b=OJ0r5u1RMmcA+pLMGnOCJ7XrhGzoB3sTDM72SCVIQK16wAr5hfNlpnZnl8N3O7t5q vkO1ehEttt2dnZ5hObqs5I+R+HNRt+p/roAfiaKQ0BtWdyZo+nOjrR4uHxICX8yjop WAxIilxrFvSqE1zps9P/pt1sA1IAqY4xFUb0pUnc= From: "josephttilahun at gmail dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 9.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: josephttilahun at gmail dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D92798 Joseph Tilahun changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |josephttilahun at gmail do= t com --- Comment #4 from Joseph Tilahun --- I encountered this same bug when using -fshort-enums with std::map iterator= s. 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 =3D false, _S_black =3D 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 =3D false, _S_black =3D 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 =3D false, _S_black =3D 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-en= ums simply exposes the fact that the _Rb_tree_color enum does not have an expli= cit underlying type. Is there a reason why the _Rb_tree_color enum does not hav= e an explicit underlying type?=