Bug 11990 - [3.4 Regression] "operand of conditional has no effect" warnings in libstdc++
Summary: [3.4 Regression] "operand of conditional has no effect" warnings in libstdc++
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 3.4.0
: P2 critical
Target Milestone: 3.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-08-20 10:23 UTC by Gerald Pfeifer
Modified: 2004-01-17 04:22 UTC (History)
2 users (show)

See Also:
Host: i386-unknown-freebsd4.8
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-08-20 14:25:52


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gerald Pfeifer 2003-08-20 10:23:06 UTC
Compile the following with -O3 -Wall:

  #include <iostream>

  using namespace std;

  int main(int argc, char **) {
    cout << "argc = " << argc;
  }

Current CVS issues the following warnings:

/gcc-current/bin/../lib/gcc/i386-unknown-freebsd4.8/3.4/../../../../include/c++/3.4/bits/locale_facets.tcc:
In
   static member function `static void std::__pad<_CharT, 
   _Traits>::_S_pad(std::ios_base&, _CharT, _CharT*, const _CharT*, streamsize, 
   streamsize, bool) [with _CharT = char, _Traits = std::char_traits<char>]':
/gcc-current/bin/../lib/gcc/i386-unknown-freebsd4.8/3.4/../../../../include/c++/3.4/bits/locale_facets.tcc:649:
  instantiated from `void std::num_put<_CharT, _OutIter>::_M_pad(_CharT,
streamsize, std::ios_base&, _CharT*, const _CharT*, int&) const [with _CharT =
char, _OutIter = std::ostreambuf_iterator<char, std::char_traits<char> >]'
/gcc-current/bin/../lib/gcc/i386-unknown-freebsd4.8/3.4/../../../../include/c++/3.4/bits/locale_facets.tcc:837:
  instantiated from `_OutIter std::num_put<_CharT,
_OutIter>::_M_insert_int(_OutIter, std::ios_base&, _CharT, _ValueT) const [with
_ValueT = long unsigned int, _CharT = char, _OutIter =
std::ostreambuf_iterator<char, std::char_traits<char> >]'
/gcc-current/bin/../lib/gcc/i386-unknown-freebsd4.8/3.4/../../../../include/c++/3.4/bits/locale_facets.tcc:1049:
  instantiated from `_OutIter std::num_put<_CharT, _OutIter>::do_put(_OutIter,
std::ios_base&, _CharT, long unsigned int) const [with _CharT = char, _OutIter =
std::ostreambuf_iterator<char, std::char_traits<char> >]'
/gcc-current/bin/../lib/gcc/i386-unknown-freebsd4.8/3.4/../../../../include/c++/3.4/bits/locale_facets.h:944:
  instantiated from `_OutIter std::num_put<_CharT, _OutIter>::put(_OutIter,
std::ios_base&, _CharT, long unsigned int) const [with _CharT = char, _OutIter =
std::ostreambuf_iterator<char, std::char_traits<char> >]'
/gcc-current/bin/../lib/gcc/i386-unknown-freebsd4.8/3.4/../../../../include/c++/3.4/bits/ostream.tcc:224:
  instantiated from `std::basic_ostream<_CharT, _Traits>&
std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT
= char, _Traits = std::char_traits<char>]'
/gcc-current/bin/../lib/gcc/i386-unknown-freebsd4.8/3.4/../../../../include/c++/3.4/ostream:196:
  instantiated from `std::basic_ostream<_CharT, _Traits>&
std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char,
_Traits = std::char_traits<char>]'
x.cc:6:   instantiated from here
/gcc-current/bin/../lib/gcc/i386-unknown-freebsd4.8/3.4/../../../../include/c++/3.4/bits/locale_facets.tcc:2241:
warning: second
   operand of conditional has no effect
/gcc-current/bin/../lib/gcc/i386-unknown-freebsd4.8/3.4/../../../../include/c++/3.4/bits/locale_facets.tcc:2241:
warning: third
   operand of conditional has no effect
Comment 1 Wolfgang Bangerth 2003-08-20 14:25:50 UTC
Confirmed. 
 
That's pretty odd code anyway: the line in question reads 
	      _Traits::eq((__news[0] = __olds[0]), __plus) ? __plus : __minus; 
and __plus and __minus are of type "const _CharT". In other words, the 
conditional really seems to have no effect. 
 
This line was checked into the file as part of version 1.78, in this commit: 
revision 1.78 
date: 2002/07/31 02:47:33;  author: bkoz;  state: Exp;  lines: +88 -74 
branches:  1.78.2;  1.78.4; 
 
2002-07-30  Benjamin Kosnik  <bkoz@redhat.com> 
            Gabriel Dos Reis  <gdr@nerim.net> 
 
	* include/bits/char_traits.h: Remove generic definitions. 
	* include/bits/streambuf_iterator.h (istreambuf_iterator): Use 
	eof, not -2. 
       [...lots more...] 
 
Benjamin, do you recall what the line was good for? 
 
W. 
Comment 2 Gerald Pfeifer 2003-08-23 07:04:29 UTC
Subject: Re:  "operand of conditional has no effect"
 warnings in libstdc++

On Sat, 23 Aug 2003, dhazeghi at yahoo dot com wrote:
> dhazeghi at yahoo dot com changed:
>
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>    Target Milestone|3.4                         |---

This is a clear, and very bad regression on mainline!  Why did you remove
the 3.4 milestone??

Gerald
Comment 3 Dara Hazeghi 2003-08-23 16:00:31 UTC
Apologies. I misread the description of the problem.
Comment 4 Gerald Pfeifer 2003-08-24 14:59:54 UTC
Patch at http://gcc.gnu.org/ml/libstdc++/2003-08/msg00214.html
Comment 5 GCC Commits 2003-08-29 17:40:17 UTC
Subject: Bug 11990

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	paolo@gcc.gnu.org	2003-08-29 17:40:12

Modified files:
	libstdc++-v3   : ChangeLog 
	libstdc++-v3/include/bits: locale_facets.tcc 

Log message:
	2003-08-29  Nathan Myers  <ncm@cantrip.org>
	
	PR libstdc++/11990
	* include/bits/locale_facets.tcc (__pad): delete dead code.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&r1=1.1946&r2=1.1947
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/locale_facets.tcc.diff?cvsroot=gcc&r1=1.110&r2=1.111

Comment 6 Paolo Carlini 2003-08-29 17:45:19 UTC
Fixed.