$ cat bug.cc #include <istream> void f(std::ios_base::seekdir dir) { switch (dir) { case std::ios_base::beg: break; case std::ios_base::cur: break; case std::ios_base::end: break; } } $ LANG=C g++-3.4.2 -Wall -c bug.cc bug.cc: In function `void f(std::_Ios_Seekdir)': bug.cc:12: warning: enumeration value `_S_ios_seekdir_end' not handled in switch bug.cc:12: warning: case value `0' not in enumerated type `_Ios_Seekdir' bug.cc:12: warning: case value `1' not in enumerated type `_Ios_Seekdir' bug.cc:12: warning: case value `2' not in enumerated type `_Ios_Seekdir' These warnings are not very usefull: the code cover all the standard values and only them but the compiler complaim about missing value and values not in the type. Yours, -- Jean-Marc
Confirmed. In fact we have: enum _Ios_Seekdir { _S_ios_seekdir_end = 1L << 16 }; class ios_base { typedef _Ios_Seekdir seekdir; static const seekdir beg = seekdir(0); static const seekdir cur = seekdir(1); static const seekdir end = seekdir(2); // more stuff ... }; The problem exists at least since gcc 3.1. In fact the code was already there in gcc 3.0, but the compiler didn't complain about it. In 2.95.3 we had: enum seek_dir { beg, cur, end}; Therefore I rate this as regression.
By the way, the other flags (e.g. openmode, iostate, fmflags) are affected by the same problem. Unfortunately, I'm not sure we can fix this within the 3.4/4.0 ABI.
could add enum _Ios_Seekdir { _S_ios_seekdir_beg = 0, _S_ios_seekdir_cur = 1, _S_ios_seekdir_end = 2 _S_ios_seekdir_final = 1L << 16 }; This would change the value of (the currently unfortunately named) _S_ios_seekdir_end, but since this is an implementation feature I think it'd be ok. Most importantly, the type size would be the same. We should add compile-only testsuite regressions for this. -benjamin
Postponed until GCC 3.4.4.
Created attachment 7456 [details] patch Fixes. When using these as case labels in switch statements, putting in the end value is necessary, or else there's a warning. I don't know what to do about that bit. Ideas?
Subject: Bug 17922 CVSROOT: /cvs/gcc Module name: gcc Changes by: bkoz@gcc.gnu.org 2004-11-02 19:00:19 Modified files: libstdc++-v3 : ChangeLog libstdc++-v3/config/io: c_io_stdio.h libstdc++-v3/include/bits: ios_base.h libstdc++-v3/src: ios.cc libstdc++-v3/testsuite: testsuite_hooks.h libstdc++-v3/testsuite/27_io/ios_base/cons: assign_neg.cc copy_neg.cc Added files: libstdc++-v3/testsuite/27_io/ios_base/types/fmtflags: bitmask_operators.cc case_label.cc libstdc++-v3/testsuite/27_io/ios_base/types/iostate: bitmask_operators.cc case_label.cc libstdc++-v3/testsuite/27_io/ios_base/types/openmode: bitmask_operators.cc case_label.cc libstdc++-v3/testsuite/27_io/ios_base/types/seekdir: case_label.cc Log message: 2004-11-02 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/17922 * include/bits/ios_base.h : Add enum values. * testsuite/testsuite_hooks.h (bitmask_operators): Add function. * testsuite/27_io/ios_base/types/fmtflags/bitmask_operators.cc: New. * testsuite/27_io/ios_base/types/fmtflags/case_label.cc: New. * testsuite/27_io/ios_base/types/iostate/bitmask_operators.cc: New. * testsuite/27_io/ios_base/types/iostate/case_label.cc: New. * testsuite/27_io/ios_base/types/openmode/bitmask_operators.cc: New. * testsuite/27_io/ios_base/types/openmode/case_label.cc: New. * testsuite/27_io/ios_base/types/seekdir/case_label.cc: New. * config/io/c_io_stdio.h (__ios_flags): Mark deprecated. * src/ios.cc: Same. * testsuite/27_io/ios_base/cons/assign_neg.cc: Adjust line numbers. * testsuite/27_io/ios_base/cons/copy_neg.cc: Same. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&r1=1.2743&r2=1.2744 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/config/io/c_io_stdio.h.diff?cvsroot=gcc&r1=1.7&r2=1.8 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/ios_base.h.diff?cvsroot=gcc&r1=1.41&r2=1.42 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/src/ios.cc.diff?cvsroot=gcc&r1=1.57&r2=1.58 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/testsuite_hooks.h.diff?cvsroot=gcc&r1=1.29&r2=1.30 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/ios_base/cons/assign_neg.cc.diff?cvsroot=gcc&r1=1.10&r2=1.11 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/ios_base/cons/copy_neg.cc.diff?cvsroot=gcc&r1=1.10&r2=1.11 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/ios_base/types/fmtflags/bitmask_operators.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/ios_base/types/fmtflags/case_label.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/ios_base/types/iostate/bitmask_operators.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/ios_base/types/iostate/case_label.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/ios_base/types/openmode/bitmask_operators.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/ios_base/types/openmode/case_label.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/ios_base/types/seekdir/case_label.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1
Subject: Bug 17922 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: bkoz@gcc.gnu.org 2004-11-08 18:02:04 Modified files: libstdc++-v3 : ChangeLog libstdc++-v3/config/io: c_io_stdio.h libstdc++-v3/include/bits: ios_base.h libstdc++-v3/src: ios.cc libstdc++-v3/testsuite: testsuite_hooks.h libstdc++-v3/testsuite/27_io/ios_base/cons: assign_neg.cc copy_neg.cc Added files: libstdc++-v3/testsuite/27_io/ios_base/types/fmtflags: bitmask_operators.cc case_label.cc libstdc++-v3/testsuite/27_io/ios_base/types/iostate: bitmask_operators.cc case_label.cc libstdc++-v3/testsuite/27_io/ios_base/types/openmode: bitmask_operators.cc case_label.cc libstdc++-v3/testsuite/27_io/ios_base/types/seekdir: case_label.cc Log message: 2004-11-08 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/17922 * include/bits/ios_base.h : Add enum values. * testsuite/testsuite_hooks.h (bitmask_operators): Add function. * testsuite/27_io/ios_base/types/fmtflags/bitmask_operators.cc: New. * testsuite/27_io/ios_base/types/fmtflags/case_label.cc: New. * testsuite/27_io/ios_base/types/iostate/bitmask_operators.cc: New. * testsuite/27_io/ios_base/types/iostate/case_label.cc: New. * testsuite/27_io/ios_base/types/openmode/bitmask_operators.cc: New. * testsuite/27_io/ios_base/types/openmode/case_label.cc: New. * testsuite/27_io/ios_base/types/seekdir/case_label.cc: New. * config/io/c_io_stdio.h (__ios_flags): Mark deprecated. * src/ios.cc: Same. * testsuite/27_io/ios_base/cons/assign_neg.cc: Adjust line numbers. * testsuite/27_io/ios_base/cons/copy_neg.cc: Same. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.2224.2.196&r2=1.2224.2.197 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/config/io/c_io_stdio.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.7&r2=1.7.10.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/ios_base.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.37.4.2&r2=1.37.4.3 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/src/ios.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.52.4.4&r2=1.52.4.5 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/testsuite_hooks.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.25.4.4&r2=1.25.4.5 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/ios_base/cons/assign_neg.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.8.4.1&r2=1.8.4.2 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/ios_base/cons/copy_neg.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.8.4.1&r2=1.8.4.2 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/ios_base/types/fmtflags/bitmask_operators.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.4.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/ios_base/types/fmtflags/case_label.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.4.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/ios_base/types/iostate/bitmask_operators.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.4.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/ios_base/types/iostate/case_label.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.4.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/ios_base/types/openmode/bitmask_operators.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.4.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/ios_base/types/openmode/case_label.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.4.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/ios_base/types/seekdir/case_label.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.4.1
Fixed.
Subject: Bug 17922 CVSROOT: /cvs/gcc Module name: gcc Branch: libstdcxx_so_7-branch Changes by: paolo@gcc.gnu.org 2005-02-21 16:58:28 Modified files: libstdc++-v3 : ChangeLog.libstdcxx_so_7-branch libstdc++-v3/config/io: c_io_stdio.h libstdc++-v3/include/bits: ios_base.h libstdc++-v3/src: ios.cc libstdc++-v3/testsuite/27_io/ios_base/cons: assign_neg.cc copy_neg.cc libstdc++-v3/testsuite/27_io/ios_base/types/fmtflags: case_label.cc libstdc++-v3/testsuite/27_io/ios_base/types/iostate: case_label.cc libstdc++-v3/testsuite/27_io/ios_base/types/openmode: case_label.cc libstdc++-v3/testsuite/27_io/ios_base/types/seekdir: case_label.cc Log message: 2005-02-21 Paolo Carlini <pcarlini@suse.de> PR libstdc++/17922 (ABI-unsafe half) * config/io/c_io_stdio.h (struct __ios_flags): Remove. * include/bits/ios_base.h (enum _Ios_Fmtflags, enum _Ios_Openmode, enum _Ios_Iostate, enum _Ios_Seekdir): Remove *_end enumerators. (class ios_base): Adjust fmtflags, iostate, openmore, seekdir static constants. * src/ios.cc: Remove definitions of __ios_flags constants. * testsuite/27_io/ios_base/types/fmtflags/case_label.cc: Adjust, removing the dummy label. * testsuite/27_io/ios_base/types/iostate/case_label.cc: Likewise. * testsuite/27_io/ios_base/types/openmode/case_label.cc: Likewise. * testsuite/27_io/ios_base/types/seekdir/case_label.cc: Likewise. * testsuite/27_io/ios_base/cons/assign_neg.cc: Adjust dg-error line numbers. * testsuite/27_io/ios_base/cons/copy_neg.cc: Likewise. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.libstdcxx_so_7-branch.diff?cvsroot=gcc&only_with_tag=libstdcxx_so_7-branch&r1=1.1.2.36&r2=1.1.2.37 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/config/io/c_io_stdio.h.diff?cvsroot=gcc&only_with_tag=libstdcxx_so_7-branch&r1=1.7.18.1&r2=1.7.18.2 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/ios_base.h.diff?cvsroot=gcc&only_with_tag=libstdcxx_so_7-branch&r1=1.40.6.3&r2=1.40.6.4 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/src/ios.cc.diff?cvsroot=gcc&only_with_tag=libstdcxx_so_7-branch&r1=1.55.6.2&r2=1.55.6.3 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/ios_base/cons/assign_neg.cc.diff?cvsroot=gcc&only_with_tag=libstdcxx_so_7-branch&r1=1.9.6.2&r2=1.9.6.3 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/ios_base/cons/copy_neg.cc.diff?cvsroot=gcc&only_with_tag=libstdcxx_so_7-branch&r1=1.9.6.2&r2=1.9.6.3 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/ios_base/types/fmtflags/case_label.cc.diff?cvsroot=gcc&only_with_tag=libstdcxx_so_7-branch&r1=1.1.6.1&r2=1.1.6.2 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/ios_base/types/iostate/case_label.cc.diff?cvsroot=gcc&only_with_tag=libstdcxx_so_7-branch&r1=1.1.6.1&r2=1.1.6.2 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/ios_base/types/openmode/case_label.cc.diff?cvsroot=gcc&only_with_tag=libstdcxx_so_7-branch&r1=1.1.6.1&r2=1.1.6.2 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/ios_base/types/seekdir/case_label.cc.diff?cvsroot=gcc&only_with_tag=libstdcxx_so_7-branch&r1=1.1.6.1&r2=1.1.6.2