Bug 17922 - [3.3/3.4 regression] Spurious warnings about std::ios_base::seekdir
Summary: [3.3/3.4 regression] Spurious warnings about std::ios_base::seekdir
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 3.4.2
: P3 minor
Target Milestone: 3.4.4
Assignee: Benjamin Kosnik
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2004-10-10 13:55 UTC by jm
Modified: 2004-11-09 10:52 UTC (History)
3 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work: 2.95.3 4.0.0
Known to fail:
Last reconfirmed: 2004-10-11 12:21:52


Attachments
patch (3.36 KB, patch)
2004-11-02 05:42 UTC, Benjamin Kosnik
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description jm 2004-10-10 13:55:17 UTC
$ 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
Comment 1 Volker Reichelt 2004-10-11 12:21:50 UTC
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.
Comment 2 Paolo Carlini 2004-10-11 14:47:14 UTC
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.
Comment 3 Benjamin Kosnik 2004-10-11 20:49:04 UTC
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
Comment 4 Mark Mitchell 2004-11-01 00:44:49 UTC
Postponed until GCC 3.4.4.
Comment 5 Benjamin Kosnik 2004-11-02 05:42:15 UTC
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?
Comment 6 GCC Commits 2004-11-02 19:00:29 UTC
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

Comment 7 GCC Commits 2004-11-08 18:02:23 UTC
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

Comment 8 Andrew Pinski 2004-11-08 18:05:06 UTC
Fixed.
Comment 9 GCC Commits 2005-02-21 16:58:37 UTC
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