Bug 12854

Summary: libstdc++ vs. -Weffc++
Product: gcc Reporter: Benjamin Kosnik <bkoz>
Component: libstdc++Assignee: Benjamin Kosnik <bkoz>
Status: RESOLVED WORKSFORME    
Severity: normal CC: gcc-bugs, mehturt
Priority: P2 Keywords: diagnostic
Version: 3.4.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2005-11-21 05:37:06
Bug Depends on: 16166, 16168, 16165, 16169, 23417    
Bug Blocks: 14172    

Description Benjamin Kosnik 2003-10-31 09:01:39 UTC
libstdc++ doesn't work well or play nicely with -Weffc++, making this
potentially useful warning message much less useful
Comment 1 Andrew Pinski 2003-10-31 22:02:17 UTC
Known and was in the FAQ section for libstdc++.
Comment 2 Benjamin Kosnik 2004-05-15 22:18:09 UTC
Mine.
Comment 3 GCC Commits 2004-05-22 23:46:47 UTC
Subject: Bug 12854

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	bkoz@gcc.gnu.org	2004-05-22 23:46:35

Modified files:
	libstdc++-v3   : ChangeLog 
	libstdc++-v3/config/locale/gnu: messages_members.h 
	                                time_members.h 
	libstdc++-v3/config/os/gnu-linux: ctype_noninline.h 
	libstdc++-v3/include/backward: strstream 
	libstdc++-v3/include/bits: basic_ios.h basic_string.h 
	                           fstream.tcc istream.tcc 
	                           locale_classes.h locale_facets.h 
	                           ostream.tcc 
	libstdc++-v3/include/debug: formatter.h safe_base.h 
	libstdc++-v3/include/ext: rope 
	libstdc++-v3/include/std: std_sstream.h std_streambuf.h 
	libstdc++-v3/src: codecvt.cc ctype.cc ios.cc locale.cc 
	                  locale_init.cc localename.cc 
	libstdc++-v3/testsuite/22_locale/money_get/get/char: 1.cc 

Log message:
	2004-05-22  Benjamin Kosnik  <bkoz@redhat.com>
	
	PR libstdc++/12854
	Fixups for -Weffc++.
	* include/bits/basic_string.h (basic_string::operator=): Return
	pointer to this instead of result of assign. Although redundant,
	this doesn't impact resultant codegen.
	
	* include/bits/locale_facets.h (__numpunct_cache): Declare
	assignment opxserator and copy constructor private.
	(__timepunct_cache): Same.
	(__moneypunct_cache): Same.
	(collate): Use member initialization list for _M_c_locale_collate.
	* config/locale/gnu/messages_members.h: Same.
	* config/locale/gnu/time_members.h (__timepunct): Same.
	* src/codecvt.cc: Use member initialization list to initialize
	_M_c_locale_codecvt.
	* src/ctype.cc: Same, with _M_c_locale_ctype and _M_narrow_ok.
	* config/os/gnu-linux/ctype_noninline.h: Same.
	* src/locale.cc (_Impl): Same.
	* src/locale_init.cc: Same.
	* src/localename.cc: Same.
	
	* include/bits/basic_ios.h (basic_ios): Complete member
	initialization list.
	* include/bits/istream.tcc (basic_istream::sentry): Same.
	* include/bits/ostream.tcc (basic_ostream::sentry): Same.
	* include/bits/fstream.tcc (basic_filebuf): Add _M_lock and
	_M_pback to member initialization list.
	* include/std/std_streambuf.h: Same.
	* include/std/std_sstream.h: Same, for _M_mode.
	* src/ios.cc (ios_base): Same.
	
	* include/ext/rope: Make derived classes match exception
	
	specifications. Add copy constructors and assignment operators.
	
	* include/debug/safe_base.h (_Safe_sequence_base): Declare copy
	constructor and assignment operator protected.
	(_Safe_iterator_base): Same.
	* include/debug/formatter.h (_Error_formatter): Define copy
	constructor and assignment operator.
	
	* include/backward/strstream: Declare assignment operator and copy
	constructor private.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&r1=1.2493&r2=1.2494
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/config/locale/gnu/messages_members.h.diff?cvsroot=gcc&r1=1.12&r2=1.13
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/config/locale/gnu/time_members.h.diff?cvsroot=gcc&r1=1.4&r2=1.5
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/config/os/gnu-linux/ctype_noninline.h.diff?cvsroot=gcc&r1=1.7&r2=1.8
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/backward/strstream.diff?cvsroot=gcc&r1=1.11&r2=1.12
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/basic_ios.h.diff?cvsroot=gcc&r1=1.28&r2=1.29
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/basic_string.h.diff?cvsroot=gcc&r1=1.59&r2=1.60
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/fstream.tcc.diff?cvsroot=gcc&r1=1.121&r2=1.122
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/istream.tcc.diff?cvsroot=gcc&r1=1.66&r2=1.67
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/locale_classes.h.diff?cvsroot=gcc&r1=1.22&r2=1.23
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/locale_facets.h.diff?cvsroot=gcc&r1=1.94&r2=1.95
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/ostream.tcc.diff?cvsroot=gcc&r1=1.52&r2=1.53
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/debug/formatter.h.diff?cvsroot=gcc&r1=1.6&r2=1.7
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/debug/safe_base.h.diff?cvsroot=gcc&r1=1.2&r2=1.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/ext/rope.diff?cvsroot=gcc&r1=1.16&r2=1.17
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/std/std_sstream.h.diff?cvsroot=gcc&r1=1.35&r2=1.36
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/std/std_streambuf.h.diff?cvsroot=gcc&r1=1.46&r2=1.47
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/src/codecvt.cc.diff?cvsroot=gcc&r1=1.20&r2=1.21
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/src/ctype.cc.diff?cvsroot=gcc&r1=1.8&r2=1.9
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/src/ios.cc.diff?cvsroot=gcc&r1=1.55&r2=1.56
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/src/locale.cc.diff?cvsroot=gcc&r1=1.109&r2=1.110
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/src/locale_init.cc.diff?cvsroot=gcc&r1=1.12&r2=1.13
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/src/localename.cc.diff?cvsroot=gcc&r1=1.54&r2=1.55
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/22_locale/money_get/get/char/1.cc.diff?cvsroot=gcc&r1=1.8&r2=1.9

Comment 4 Benjamin Kosnik 2004-05-23 17:17:45 UTC
This is fixed to the fullest extent possible. The remaining bits that warn with
-Weffc++ are either mandated by the standard, or required for performance/size
reasons by ABI implementations.

So, I'd like to either close this or put it into suspended.
Comment 5 Gabriel Dos Reis 2004-05-23 17:56:11 UTC
Subject: Re:  libstdc++ vs. -Weffc++

"bkoz at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| This is fixed to the fullest extent possible. The remaining bits
| that warn with -Weffc++ are either mandated by the standard, or
| required for performance/size reasons by ABI implementations.
| 
| So, I'd like to either close this or put it into suspended.

We also need to investigate why instantiations of templates defined in
system headers are trigerring remarks from the compiler when we don't
have -Wsystem-headers.

-- Gaby


 
Comment 6 Benjamin Kosnik 2004-05-24 18:39:55 UTC
suspending...
Comment 7 GCC Commits 2004-05-24 20:50:05 UTC
Subject: Bug 12854

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	bkoz@gcc.gnu.org	2004-05-24 20:49:55

Modified files:
	libstdc++-v3   : ChangeLog 
	libstdc++-v3/config/locale/gnu: messages_members.h 
	                                time_members.h 
	libstdc++-v3/config/os/gnu-linux: ctype_noninline.h 
	libstdc++-v3/include/backward: strstream 
	libstdc++-v3/include/bits: basic_ios.h basic_string.h 
	                           fstream.tcc istream.tcc 
	                           locale_classes.h locale_facets.h 
	                           ostream.tcc 
	libstdc++-v3/include/debug: formatter.h safe_base.h 
	libstdc++-v3/include/ext: rope 
	libstdc++-v3/include/std: std_sstream.h std_streambuf.h 
	libstdc++-v3/src: codecvt.cc ctype.cc ios.cc locale.cc 
	                  locale_init.cc localename.cc 
	libstdc++-v3/testsuite/22_locale/money_get/get/char: 1.cc 

Log message:
	2004-05-24  Benjamin Kosnik  <bkoz@redhat.com>
	
	PR libstdc++/12854
	Fixups for -Weffc++.
	* include/bits/basic_string.h (basic_string::operator=): Return
	pointer to this instead of result of assign. Although redundant,
	this doesn't impact resultant codegen.
	
	* include/bits/locale_facets.h (__numpunct_cache): Declare
	assignment opxserator and copy constructor private.
	(__timepunct_cache): Same.
	(__moneypunct_cache): Same.
	(collate): Use member initialization list for _M_c_locale_collate.
	* config/locale/gnu/messages_members.h: Same.
	* config/locale/gnu/time_members.h (__timepunct): Same.
	* src/codecvt.cc: Use member initialization list to initialize
	_M_c_locale_codecvt.
	* src/ctype.cc: Same, with _M_c_locale_ctype and _M_narrow_ok.
	* config/os/gnu-linux/ctype_noninline.h: Same.
	* src/locale.cc (_Impl): Same.
	* src/locale_init.cc: Same.
	* src/localename.cc: Same.
	
	* include/bits/basic_ios.h (basic_ios): Complete member
	initialization list.
	* include/bits/istream.tcc (basic_istream::sentry): Same.
	* include/bits/ostream.tcc (basic_ostream::sentry): Same.
	* include/bits/fstream.tcc (basic_filebuf): Add _M_lock and
	_M_pback to member initialization list.
	* include/std/std_streambuf.h: Same.
	* include/std/std_sstream.h: Same, for _M_mode.
	* src/ios.cc (ios_base): Same.
	
	* include/ext/rope: Make derived classes match exception
	
	specifications. Add copy constructors and assignment operators.
	
	* include/debug/safe_base.h (_Safe_sequence_base): Declare copy
	constructor and assignment operator protected.
	(_Safe_iterator_base): Same.
	* include/debug/formatter.h (_Error_formatter): Define copy
	constructor and assignment operator.
	
	* include/backward/strstream: Declare assignment operator and copy
	constructor private.

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.113&r2=1.2224.2.114
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/config/locale/gnu/messages_members.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.11.10.1&r2=1.11.10.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/config/locale/gnu/time_members.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.4&r2=1.4.12.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/config/os/gnu-linux/ctype_noninline.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.7&r2=1.7.4.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/backward/strstream.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.11&r2=1.11.4.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/basic_ios.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.27.4.1&r2=1.27.4.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/basic_string.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.41.4.4&r2=1.41.4.5
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/fstream.tcc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.116.4.5&r2=1.116.4.6
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/istream.tcc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.60.4.3&r2=1.60.4.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/locale_classes.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.18.4.2&r2=1.18.4.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/locale_facets.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.85.2.5&r2=1.85.2.6
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/ostream.tcc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.50.4.1&r2=1.50.4.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/debug/formatter.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.5.8.1&r2=1.5.8.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/debug/safe_base.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.2&r2=1.2.8.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/ext/rope.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.15.4.1&r2=1.15.4.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/std/std_sstream.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.35&r2=1.35.10.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/std/std_streambuf.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.46&r2=1.46.4.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/src/codecvt.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.19.10.1&r2=1.19.10.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/src/ctype.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.7.4.1&r2=1.7.4.2
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.3&r2=1.52.4.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/src/locale.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.103.4.4&r2=1.103.4.5
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/src/locale_init.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.6.4.3&r2=1.6.4.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/src/localename.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.51.4.2&r2=1.51.4.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/22_locale/money_get/get/char/1.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.6.4.2&r2=1.6.4.3

Comment 8 Benjamin Kosnik 2004-06-28 19:48:54 UTC
So, I put the c++ "enhancement" requests as blockers to this bug. 

I think -Weffc++ is now usable on mainline, but before I do any more work on
this stuff, I'd like to see the g++ side make some efforts at helping me.

-benjamin
Comment 9 Andrew Pinski 2005-08-16 18:57:35 UTC
(In reply to comment #5)
> We also need to investigate why instantiations of templates defined in
> system headers are trigerring remarks from the compiler when we don't
> have -Wsystem-headers.

This is filed under PR 14172.
Comment 10 Gabriel Dos Reis 2005-11-26 09:12:57 UTC
(In reply to comment #8)
> So, I put the c++ "enhancement" requests as blockers to this bug. 
> 
> I think -Weffc++ is now usable on mainline, but before I do any more work on
> this stuff, I'd like to see the g++ side make some efforts at helping me.
> 
> -benjamin

By default, we no longer issue warning in system headers -- that was fixed
by Mark Mitchell I think.
But we issue still issue warning on demand (-Wsystem-headers).  And I 
believe, that is OK.
What do you think?
Comment 11 Paolo Carlini 2010-02-15 01:45:20 UTC
I think this can be closed: now the system header pragma is pretty solid and I don't think warnings can be triggered from library headers, by any -W option.