Package: g++-4.3 Version: 4.3.2-1.1 When compiling a program which used the C++ STL to contain instances of a class of my own devising, I encountered spurious warnings. I have been able to reduce the necessary code to a simple test case, which is included in this bug report along with a transcript of the spurious warninngs seen when compiling it.
morme...@fangasm:~/src/dungeonbash-2.0.0$ uname -a Linux fangasm 2.6.26-1-686 #1 SMP Wed Nov 26 19:14:11 UTC 2008 i686 GNU/Linux morme...@fangasm:~/src/dungeonbash-2.0.0$ g++ --version g++ (Debian 4.3.2-1.1) 4.3.2 Copyright (C) 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. morme...@fangasm:~/src/dungeonbash-2.0.0$ make coordtest g++ -c -g -Wall -Wwrite-strings -Wredundant-decls -Wunreachable-code -DMAJVERS=2 -DMINVERS=0 -DPATCHVERS=0 -c -o coordtest.o coordtest.cc coordtest.cc: In member function âT libmrl::basic_coord<T>::distance(const libmrl::basic_coord<T>&) const [with T = int]â: coordtest.cc:28: warning: will never be executed coordtest.cc: In member function âbool libmrl::basic_coord<T>::operator<(const libmrl::basic_coord<T>&) const [with T = int]â: coordtest.cc:20: warning: will never be executed /usr/include/c++/4.3/bits/stl_tree.h: In member function âstd::_Rb_tree_node<_Val>* std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_create_node(const _Val&) [with _Key = libmrl::basic_coord<int>, _Val = libmrl::basic_coord<int>, _KeyOfValue = std::_Identity<libmrl::basic_coord<int> >, _Compare = std::less<libmrl::basic_coord<int> >, _Alloc = std::allocator<libmrl::basic_coord<int> >]â: /usr/include/c++/4.3/bits/stl_tree.h:369: warning: will never be executed /usr/include/c++/4.3/bits/stl_tree.h:372: warning: will never be executed /usr/include/c++/4.3/bits/stl_tree.h:369: warning: will never be executed g++ coordtest.o -o coordtest morme...@fangasm:~/src/dungeonbash-2.0.0$ morme...@fangasm:~$ ls -l /lib/libc.so.6 lrwxrwxrwx 1 root root 11 2008-12-17 22:00 /lib/libc.so.6 -> libc-2.7.so morme...@fangasm:~$ The test case follows: #include <cstdio> #include <list> #include <set> namespace libmrl { template <typename T> class basic_coord { public: T y; T x; basic_coord<T>& operator -=(basic_coord<T> const& right) throw() { y -= right.y; x -= right.x; return *this; } basic_coord<T>& operator +=(basic_coord<T> const& right) throw() { y += right.y; x += right.x; return *this; } bool operator < (basic_coord<T> const& right) const throw() { return (y < right.y) || ((y == right.y) && (x < right.x)); } bool operator == (basic_coord<T> const& right) const throw() { return (y == right.y) && (x == right.x); } T distance(basic_coord<T> const& right) const throw() { T dy, dx; dy = right.y - y; dx = right.x - x; if (dy < 0) dy = -dy; if (dx < 0) dx = -dx; return (dy > dx) ? dy : dx; } }; typedef basic_coord<int> Coord; } int main() { libmrl::Coord c = { 1, 2 }; libmrl::Coord d = { 3, 4 }; std::printf("%d %d to %d %d: distance %d or %d\n", c.y, c.x, d.y, d.x, c.distance(d), d.distance(c)); std::list<libmrl::Coord> oink; oink.push_front(c); oink.push_front(d); std::printf("%d\n", oink.size()); std::set<libmrl::Coord> spang; spang.insert(c); spang.insert(d); std::printf("%d\n", spang.size()); } -- To UNSUBSCRIBE, email to debian-gcc-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org