From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2379 invoked by alias); 10 Mar 2002 15:06:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 2333 invoked by uid 71); 10 Mar 2002 15:06:00 -0000 Resent-Date: 10 Mar 2002 15:06:00 -0000 Resent-Message-ID: <20020310150600.2332.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, Peter Schmid Received:(qmail 28198 invoked from network); 10 Mar 2002 15:02:48 -0000 Received: from unknown (HELO snake.iap.physik.tu-darmstadt.de) (130.83.4.87) by sources.redhat.com with SMTP; 10 Mar 2002 15:02:48 -0000 Received: (from schmid@localhost) by snake.iap.physik.tu-darmstadt.de (8.9.3/8.9.3/SuSE Linux 8.9.3-0.1) id RAA22762; Sun, 10 Mar 2002 17:02:59 +0100 Message-Id:<200203101602.RAA22762@snake.iap.physik.tu-darmstadt.de> Date: Sun, 10 Mar 2002 07:06:00 -0000 From: Peter Schmid To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:3.113 Subject: c++/5908: Warning regression wrt. gcc 3.0 X-SW-Source: 2002-03/txt/msg00315.txt.bz2 List-Id: >Number: 5908 >Category: c++ >Synopsis: Warning regression wrt. gcc 3.0 >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Sun Mar 10 07:06:00 PST 2002 >Closed-Date: >Last-Modified: >Originator: Peter Schmid >Release: 3.1 20020306 (prerelease) >Organization: TU Darmstadt >Environment: System: Linux kiste 2.4.18 #8 Sat Mar 9 15:33:15 CET 2002 i686 unknown Architecture: i686 SuSE 7.3 GNU ld version 020305 20020305 glibc 2.2.4 + patches host: i686-pc-linux-gnu build: i686-pc-linux-gnu target: i686-pc-linux-gnu configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads --enable-languages=c,c++,f77,objc >Description: There is an IMHO bogus "value computed is not used" warning in the following code re.C, a stripped down version of: #include typedef std::map previous_results_type; previous_results_type read_previous_results() { previous_results_type result; return result; } int main() { previous_results_type previous_results; previous_results = read_previous_results(); } gcc 2.95, 3.0 and gcc 3.1 older than two weeks do not issue this warning. If my opinon is wrong the map and other container headers from libstdc++ should be fixed. When the template _Rb_tree<_Key,_Value,_KeyOfValue,_Compare>& _Rb_tree<_Key,_Value,_KeyOfValue,_Compare> ::operator=(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare>& __x) method is removed, the warning disappers. >How-To-Repeat: Source code re.C namespace std { template struct pair { typedef _T1 first_type; typedef _T2 second_type; _T1 first; _T2 second; pair() : first(), second() {} pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) {} }; template struct less { bool operator()(const _Tp& __x, const _Tp& __y) const { return __x < __y; } }; template class _Rb_tree { protected: _Compare _M_key_compare; public: _Rb_tree(const _Compare& __comp) : _M_key_compare(__comp) {} _Rb_tree<_Key,_Value,_KeyOfValue,_Compare>& operator=(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare>& __x); }; template _Rb_tree<_Key,_Value,_KeyOfValue,_Compare>& _Rb_tree<_Key,_Value,_KeyOfValue,_Compare> ::operator=(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare>& __x) { if (this != &__x) { _M_key_compare = __x._M_key_compare; } return *this; } template > class map { public: typedef _Key key_type; typedef pair value_type; typedef _Compare key_compare; private: typedef _Rb_tree _Rep_type; _Rep_type _M_t; public: map() : _M_t(_Compare()) {} map<_Key,_Tp,_Compare>& operator=(const map<_Key, _Tp, _Compare>& __x) { _M_t = __x._M_t; return *this; } }; } typedef std::map previous_results_type; previous_results_type read_previous_results() { previous_results_type result; return result; } int main() { previous_results_type previous_results; previous_results = read_previous_results(); } g++ -v -o re re.C -W -Wall -save-temps Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/specs Configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads --enable-languages=c,c++,f77,objc Thread model: posix gcc version 3.1 20020306 (prerelease) /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/cpp0 -lang-c++ -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -v -D__GNUC__=3 -D__GNUC_MINOR__=1 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ re.C -W -Wall re.ii GNU CPP version 3.1 20020306 (prerelease) (cpplib) (i386 Linux/ELF) ignoring nonexistent directory "NONE/include" ignoring nonexistent directory "/usr/local/i686-pc-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/local/include/g++-v3 /usr/local/include/g++-v3/i686-pc-linux-gnu /usr/local/include/g++-v3/backward /usr/local/include /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/include /usr/include End of search list. /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/cc1plus -fpreprocessed re.ii -quiet -dumpbase re.C -W -Wall -version -o re.s GNU CPP version 3.1 20020306 (prerelease) (cpplib) (i386 Linux/ELF) GNU C++ version 3.1 20020306 (prerelease) (i686-pc-linux-gnu) compiled by GNU C version 3.1 20020306 (prerelease). re.C: In member function `std::_Rb_tree<_Key, _Value, _KeyOfValue, _Compare>& std::_Rb_tree<_Key, _Value, _KeyOfValue, _Compare>::operator=(const std::_Rb_tree<_Key, _Value, _KeyOfValue, _Compare>&) [with _Key = int, _Value = std::pair, _KeyOfValue = const int, _Compare = std::less]': re.C:58: instantiated from `std::map<_Key, _Tp, _Compare>& std::map<_Key, _Tp, _Compare>::operator=(const std::map<_Key, _Tp, _Compare>&) [with _Key = int, _Tp = int, _Compare = std::less]' re.C:75: instantiated from here re.C:37: warning: value computed is not used /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/../../../../i686-pc-linux-gnu/bin/as -V -Qy -o re.o re.s GNU assembler version 020305 (i686-pc-linux-gnu) using BFD version 020305 20020305 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/collect2 --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o re /usr/lib/crt1.o /usr/lib/crti.o /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/crtbegin.o -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1 -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/../../../../i686-pc-linux-gnu/lib -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/../../.. re.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/crtend.o /usr/lib/crtn.o preprocessed source file re.ii # 1 "re.C" # 1 "" # 1 "" # 1 "re.C" namespace std { template struct pair { typedef _T1 first_type; typedef _T2 second_type; _T1 first; _T2 second; pair() : first(), second() {} pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) {} }; template struct less { bool operator()(const _Tp& __x, const _Tp& __y) const { return __x < __y; } }; template class _Rb_tree { protected: _Compare _M_key_compare; public: _Rb_tree(const _Compare& __comp) : _M_key_compare(__comp) {} _Rb_tree<_Key,_Value,_KeyOfValue,_Compare>& operator=(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare>& __x); }; template _Rb_tree<_Key,_Value,_KeyOfValue,_Compare>& _Rb_tree<_Key,_Value,_KeyOfValue,_Compare> ::operator=(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare>& __x) { if (this != &__x) { _M_key_compare = __x._M_key_compare; } return *this; } template > class map { public: typedef _Key key_type; typedef pair value_type; typedef _Compare key_compare; private: typedef _Rb_tree _Rep_type; _Rep_type _M_t; public: map() : _M_t(_Compare()) {} map<_Key,_Tp,_Compare>& operator=(const map<_Key, _Tp, _Compare>& __x) { _M_t = __x._M_t; return *this; } }; } typedef std::map previous_results_type; previous_results_type read_previous_results() { previous_results_type result; return result; } int main() { previous_results_type previous_results; previous_results = read_previous_results(); } >Fix: >Release-Note: >Audit-Trail: >Unformatted: