[Bug libstdc++/67996] New: std::ios_base::seekdir raises -Wswitch with Clang
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67996 Bug ID: 67996 Summary: std::ios_base::seekdir raises -Wswitch with Clang Product: gcc Version: 4.6.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: kim.grasman at gmail dot com Target Milestone: --- When using libstdc++ with Clang, we can't seem to form a fully-covered switch over std::ios_base::seekdir: void f(std::ios_base::seekdir way) switch(way) { case std::ios_base::beg: // ... break; case std::ios_base::cur: // ... break; case std::ios_base::end: // ... break; } } ...t.cc:87:12: warning: enumeration value '_S_ios_seekdir_end' not handled in switch [-Wswitch] switch (way) This looks like it was discussed long ago in #17922, so I don't know if this has regressed or if it's something about Clang's implementation of this diagnostic that is different from GCC. A discussion on the Clang list is available here: http://article.gmane.org/gmane.comp.compilers.clang.devel/45198/match=overeager What's the motivation for _S_ios_seekdir_end? Any chance it could be removed? Thanks!
[Bug libstdc++/67996] std::ios_base::seekdir raises -Wswitch with Clang
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67996 --- Comment #2 from Kim Gräsman --- Thanks, I figured that was why. The warning is not a problem if I'm using directly, then I can just disable it locally. But we ran into this with a third-party library having the code above in one of their headers. This makes it nigh-impossible for us to enable -Wswitch for our own code, as the third-party header could be indirectly included in any translation unit. ios: enum seekdir { beg, cur, end, _S_ios_seekdir_end }; third-party.h: switch(seekdir) { case beg: break; case cur: break; case end: break; } us.cpp: #include "third-party.h" // WARN I wasn't sure if the extra enumerator was allowed by the standard, so thanks for confirming that. We've now worked around it by patching the third-party to use an if/else chain instead, but I thought I'd raise it anyway because it creates a messy situation when the warning "leaks" like this.
[Bug libstdc++/67996] std::ios_base::seekdir raises -Wswitch with Clang
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67996 --- Comment #4 from Kim Gräsman --- FWIW, it turns out that GCC warns, too: $ g++ -Iinclude -I/ssd/code/poco/CppUnit/include -I/ssd/code/poco/CppUnit/WinTestRunner/include -I/ssd/code/poco/Foundation/include -I/ssd/code/poco/XML/include -I/ssd/code/poco/Util/include -I/ssd/code/poco/Net/include -I/ssd/code/poco/Crypto/include -I/ssd/code/poco/NetSSL_OpenSSL/include -I/ssd/code/poco/Data/include -I/ssd/code/poco/Data/SQLite/include -I/ssd/code/poco/Data/ODBC/include -I/ssd/code/poco/Data/MySQL/include -I/ssd/code/poco/Zip/include -I/ssd/code/poco/PageCompiler/include -I/ssd/code/poco/PageCompiler/File2Page/include -I/ssd/code/poco/PDF/include -I/ssd/code/poco/CppParser/include -I/ssd/code/poco/MongoDB/include -I/ssd/code/poco/PocoDoc/include -I/ssd/code/poco/ProGen/include -Wall -Wno-sign-compare -DPOCO_UTIL_NO_JSONCONFIGURATION -DPOCO_HAVE_IPv6 -D_XOPEN_SOURCE=500 -D_REENTRANT -D_THREAD_SAFE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -DPOCO_HAVE_FD_EPOLL -O2 -DNDEBUG -fPIC -c src/MemoryStream.cpp -o /ssd/code/poco/Foundation/obj/Linux/x86_64/release_shared/MemoryStream.o In file included from src/MemoryStream.cpp:17:0: include/Poco/MemoryStream.h: In instantiation of ‘Poco::BasicMemoryStreamBuf::pos_type Poco::BasicMemoryStreamBuf::seekoff(Poco::BasicMemoryStreamBuf::off_type, std::ios_base::seekdir, std::ios_base::openmode) [with ch = char; tr = std::char_traits; Poco::BasicMemoryStreamBuf::pos_type = std::fpos<__mbstate_t>; Poco::BasicMemoryStreamBuf::off_type = long int; std::ios_base::seekdir = std::_Ios_Seekdir; std::ios_base::openmode = std::_Ios_Openmode]’: src/MemoryStream.cpp:59:1: required from here include/Poco/MemoryStream.h:87:4: warning: enumeration value ‘_S_ios_seekdir_end’ not handled in switch [-Wswitch] switch (way) ^ include/Poco/MemoryStream.h:113:4: warning: enumeration value ‘_S_ios_seekdir_end’ not handled in switch [-Wswitch] switch (way) ^ This is the age-old GCC 4.6.3 that we're stuck on, however, later versions may be more forgiving.