public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/23632] New: std::vector<bool> in combination with debug mode fails to compile code
@ 2005-08-30 11:54 fischerk at inf dot ethz dot ch
2005-08-30 11:55 ` [Bug libstdc++/23632] " fischerk at inf dot ethz dot ch
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: fischerk at inf dot ethz dot ch @ 2005-08-30 11:54 UTC (permalink / raw)
To: gcc-bugs
Dear libstdc++ coders,
I think I discovered a bug in the debug mode of gcc-4.0.0. It is the following program that should
compile using the debug mode but that does not.
// BEGIN
#include <vector>
int main(int,char **)
{
std::vector<bool> v(100);
const std::vector<bool>::const_iterator fu = v.begin();
if (fu[4])
;
}
// END
If I compile it via
/Users/hbf/sw/gcc-4.0.0/bin/g++ -v -save-temps -D_GLIBCXX_DEBUG test2.C -o test2
then I obtain the following output:
// BEGIN OUTPUT
Using built-in specs.
Target: powerpc-apple-darwin8.1.0
Configured with: ../gcc-4.0.0/configure --prefix=/Users/hbf/sw/gcc-4.0.0 --enable-languages=c++
Thread model: posix
gcc version 4.0.0
/Users/hbf/sw/gcc-4.0.0/libexec/gcc/powerpc-apple-darwin8.1.0/4.0.0/cc1plus -E -quiet -v -
D__DYNAMIC__ -D__APPLE_CC__=1 -D_GLIBCXX_DEBUG test2.C -fPIC -fpch-preprocess -o test2.ii
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/Users/hbf/sw/gcc-4.0.0/lib/gcc/powerpc-apple-
darwin8.1.0/4.0.0/../../../../powerpc-apple-darwin8.1.0/include"
#include "..." search starts here:
#include <...> search starts here:
/Users/hbf/sw/gcc-4.0.0/lib/gcc/powerpc-apple-darwin8.1.0/4.0.0/../../../../include/c++/4.0.0
/Users/hbf/sw/gcc-4.0.0/lib/gcc/powerpc-apple-darwin8.1.0/4.0.0/../../../../include/c++/4.0.0/
powerpc-apple-darwin8.1.0
/Users/hbf/sw/gcc-4.0.0/lib/gcc/powerpc-apple-darwin8.1.0/4.0.0/../../../../include/c++/4.0.0/
backward
/Users/hbf/sw/gcc-4.0.0/include
/Users/hbf/sw/gcc-4.0.0/lib/gcc/powerpc-apple-darwin8.1.0/4.0.0/include
/usr/include
/System/Library/Frameworks
/Library/Frameworks
End of search list.
/Users/hbf/sw/gcc-4.0.0/libexec/gcc/powerpc-apple-darwin8.1.0/4.0.0/cc1plus -fpreprocessed
test2.ii -fPIC -quiet -dumpbase test2.C -auxbase test2 -version -o test2.s
GNU C++ version 4.0.0 (powerpc-apple-darwin8.1.0)
compiled by GNU C version 4.0.0.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
/Users/hbf/sw/gcc-4.0.0/lib/gcc/powerpc-apple-darwin8.1.0/4.0.0/../../../../include/c++/4.0.0/
debug/safe_iterator.h: In member function 'typename std::iterator_traits<_Iterator>::reference
__gnu_debug::_Safe_iterator<_Iterator, _Sequence>::operator[](const typename
std::iterator_traits<_Iterator>::difference_type&) const [with _Iterator =
__gnu_norm::_Bit_const_iterator, _Sequence = __gnu_debug_def::vector<bool, std::allocator<bool> >]':
test2.C:7: instantiated from here
/Users/hbf/sw/gcc-4.0.0/lib/gcc/powerpc-apple-darwin8.1.0/4.0.0/../../../../include/c++/4.0.0/
debug/safe_iterator.h:270: error: passing 'const __gnu_norm::_Bit_const_iterator' as 'this' argument of
'bool __gnu_norm::_Bit_const_iterator::operator[](ptrdiff_t)' discards qualifiers
// END OUTPUT
I will attach the test2.s and test2.ii files for the above call.
Could it be that in order to fix this, you have to add to class _Bit_const_iterator an "operator[] const"?
Currently, _Bit_const_iterator only provides a non-const member "operator[]". If I add in file gcc-4.0.0/
include/c++/4.0.0/bits/stl_bvector.h after line 345:
const_reference
operator[](difference_type __i) const // Note: it is const.
{ return *(*this + __i); }
Then the above code compiles fine.
Thanks for your work!
Kaspar
--
Summary: std::vector<bool> in combination with debug mode fails
to compile code
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: minor
Priority: P2
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: fischerk at inf dot ethz dot ch
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: Using built-in specs.
GCC host triplet: powerpc-apple-darwin8.1.0
GCC target triplet: powerpc-apple-darwin8.1.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23632
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/23632] std::vector<bool> in combination with debug mode fails to compile code
2005-08-30 11:54 [Bug libstdc++/23632] New: std::vector<bool> in combination with debug mode fails to compile code fischerk at inf dot ethz dot ch
@ 2005-08-30 11:55 ` fischerk at inf dot ethz dot ch
2005-08-30 12:26 ` fischerk at inf dot ethz dot ch
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: fischerk at inf dot ethz dot ch @ 2005-08-30 11:55 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From fischerk at inf dot ethz dot ch 2005-08-30 11:54 -------
Created an attachment (id=9620)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=9620&action=view)
ii-output from g++ -v -save-temps
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23632
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/23632] std::vector<bool> in combination with debug mode fails to compile code
2005-08-30 11:54 [Bug libstdc++/23632] New: std::vector<bool> in combination with debug mode fails to compile code fischerk at inf dot ethz dot ch
2005-08-30 11:55 ` [Bug libstdc++/23632] " fischerk at inf dot ethz dot ch
@ 2005-08-30 12:26 ` fischerk at inf dot ethz dot ch
2005-08-30 14:34 ` pcarlini at suse dot de
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: fischerk at inf dot ethz dot ch @ 2005-08-30 12:26 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From fischerk at inf dot ethz dot ch 2005-08-30 11:55 -------
Created an attachment (id=9621)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=9621&action=view)
s-output from g++ -v -save-temps
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23632
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/23632] std::vector<bool> in combination with debug mode fails to compile code
2005-08-30 11:54 [Bug libstdc++/23632] New: std::vector<bool> in combination with debug mode fails to compile code fischerk at inf dot ethz dot ch
2005-08-30 11:55 ` [Bug libstdc++/23632] " fischerk at inf dot ethz dot ch
2005-08-30 12:26 ` fischerk at inf dot ethz dot ch
@ 2005-08-30 14:34 ` pcarlini at suse dot de
2005-08-30 14:38 ` fischerk at inf dot ethz dot ch
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pcarlini at suse dot de @ 2005-08-30 14:34 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pcarlini at suse dot de 2005-08-30 14:28 -------
Happens also mornally, in non-debug mode. It's a very old issue, maybe fixing it
it's rather easy...
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |pcarlini at suse dot de
|dot org |
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2005-08-30 14:28:30
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23632
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/23632] std::vector<bool> in combination with debug mode fails to compile code
2005-08-30 11:54 [Bug libstdc++/23632] New: std::vector<bool> in combination with debug mode fails to compile code fischerk at inf dot ethz dot ch
` (2 preceding siblings ...)
2005-08-30 14:34 ` pcarlini at suse dot de
@ 2005-08-30 14:38 ` fischerk at inf dot ethz dot ch
2005-08-30 15:03 ` pcarlini at suse dot de
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: fischerk at inf dot ethz dot ch @ 2005-08-30 14:38 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From fischerk at inf dot ethz dot ch 2005-08-30 14:37 -------
Sorry, my mistake, the code is sent was not the right one. (I tested around and did not realize that I
sent the wrong one, sorry.) Here is the code that causes the problem; and it only happens when I
compile using the debug mode:
// BEGIN
#include <vector>
int main(int,char **)
{
std::vector<bool> v(100);
std::vector<bool>::const_iterator fu = v.begin(); // no const in front of the line
if (fu[4])
;
}
// END
Tell me if you again need the .ii and .s-files.
Sorry for the confusion.
Kaspar
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23632
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/23632] std::vector<bool> in combination with debug mode fails to compile code
2005-08-30 11:54 [Bug libstdc++/23632] New: std::vector<bool> in combination with debug mode fails to compile code fischerk at inf dot ethz dot ch
` (3 preceding siblings ...)
2005-08-30 14:38 ` fischerk at inf dot ethz dot ch
@ 2005-08-30 15:03 ` pcarlini at suse dot de
2005-08-31 17:23 ` cvs-commit at gcc dot gnu dot org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pcarlini at suse dot de @ 2005-08-30 15:03 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pcarlini at suse dot de 2005-08-30 14:41 -------
Ok, thanks. No, nothing else is needed, the problem is clear.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23632
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/23632] std::vector<bool> in combination with debug mode fails to compile code
2005-08-30 11:54 [Bug libstdc++/23632] New: std::vector<bool> in combination with debug mode fails to compile code fischerk at inf dot ethz dot ch
` (4 preceding siblings ...)
2005-08-30 15:03 ` pcarlini at suse dot de
@ 2005-08-31 17:23 ` cvs-commit at gcc dot gnu dot org
2005-08-31 19:18 ` pcarlini at suse dot de
2005-09-07 10:24 ` pcarlini at suse dot de
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-08-31 17:23 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2005-08-31 17:02 -------
Subject: Bug 23632
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: paolo@gcc.gnu.org 2005-08-31 17:01:57
Modified files:
libstdc++-v3 : ChangeLog
libstdc++-v3/include/bits: stl_bvector.h
Added files:
libstdc++-v3/testsuite/23_containers/vector/bool: 23632.cc
Log message:
2005-08-31 Paolo Carlini <pcarlini@suse.de>
Kaspar Fischer <fischerk@inf.ethz.ch>
PR libstdc++/23632
* include/bits/stl_bvector.h (_Bit_iterator::operator[],
_Bit_const_iterator::operator[]): Const-ify.
* testsuite/23_containers/vector/bool/23632.cc: New.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&r1=1.3087&r2=1.3088
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_bvector.h.diff?cvsroot=gcc&r1=1.44&r2=1.45
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/vector/bool/23632.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23632
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/23632] std::vector<bool> in combination with debug mode fails to compile code
2005-08-30 11:54 [Bug libstdc++/23632] New: std::vector<bool> in combination with debug mode fails to compile code fischerk at inf dot ethz dot ch
` (5 preceding siblings ...)
2005-08-31 17:23 ` cvs-commit at gcc dot gnu dot org
@ 2005-08-31 19:18 ` pcarlini at suse dot de
2005-09-07 10:24 ` pcarlini at suse dot de
7 siblings, 0 replies; 9+ messages in thread
From: pcarlini at suse dot de @ 2005-08-31 19:18 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.0.2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23632
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/23632] std::vector<bool> in combination with debug mode fails to compile code
2005-08-30 11:54 [Bug libstdc++/23632] New: std::vector<bool> in combination with debug mode fails to compile code fischerk at inf dot ethz dot ch
` (6 preceding siblings ...)
2005-08-31 19:18 ` pcarlini at suse dot de
@ 2005-09-07 10:24 ` pcarlini at suse dot de
7 siblings, 0 replies; 9+ messages in thread
From: pcarlini at suse dot de @ 2005-09-07 10:24 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pcarlini at suse dot de 2005-09-07 10:23 -------
Not a regression, in any sense. Given that, and the "almost-deprecated" status
of vector<bool>, better not touching this for the current release branch. Fixed
for 4.1.0, anyway.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|4.0.2 |4.1.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23632
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2005-09-07 10:24 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-30 11:54 [Bug libstdc++/23632] New: std::vector<bool> in combination with debug mode fails to compile code fischerk at inf dot ethz dot ch
2005-08-30 11:55 ` [Bug libstdc++/23632] " fischerk at inf dot ethz dot ch
2005-08-30 12:26 ` fischerk at inf dot ethz dot ch
2005-08-30 14:34 ` pcarlini at suse dot de
2005-08-30 14:38 ` fischerk at inf dot ethz dot ch
2005-08-30 15:03 ` pcarlini at suse dot de
2005-08-31 17:23 ` cvs-commit at gcc dot gnu dot org
2005-08-31 19:18 ` pcarlini at suse dot de
2005-09-07 10:24 ` pcarlini at suse dot de
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).