public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/33613]  New: compilation inconsistency upper_bound vs lower_bound with -D_GLIBCXX_DEBUG
@ 2007-10-01 19:53 leo dot moisio at gmail dot com
  2007-10-01 19:55 ` [Bug libstdc++/33613] " leo dot moisio at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: leo dot moisio at gmail dot com @ 2007-10-01 19:53 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3880 bytes --]

The following code fails to compile when -D_GLIBCXX_DEBUG is used. If
-D_GLIBCXX_DEBUG is not used, or the upper_bound call is commented out, the
code compiles fine.

////////////////////////////// test.cc begin
#include <algorithm>
struct A {};
struct B {};
bool ab(A, B);
bool ba(B, A);
void test(A* a, B b)
{
        std::lower_bound(a,a,b, ab);
        std::upper_bound(a,a,b, ba);
}
/////////////////////////////// test.cc end

Expected behaviour is that since everything compiles without the define, it
would also compile with the define, and since lower_bound call compiles even
with that, then at least both lower_bound and upper_bound would either both
fail or both compile.

The current behaviour of just upper_bound failing and only with that define is
confusing at best.

Perhaps you could add a check that the iterator sequence iterates elements of
the same type as the third parameter, or if this should not be required, make
that noncompiling case compile too.

$ g++ -v -save-temps -D_GLIBCXX_DEBUG test.cc
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2
--enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr
--enable-targets=all --disable-werror --enable-checking=release
--build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.2.1 (Debian 4.2.1-5)
 /usr/lib/gcc/i486-linux-gnu/4.2.1/cc1plus -E -quiet -v -D_GNU_SOURCE
-D_GLIBCXX_DEBUG test.cc -mtune=generic -fpch-preprocess -o test.ii
ignoring nonexistent directory "/usr/local/include/i486-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/i486-linux-gnu/4.2.1/../../../../i486-linux-gnu/include"
ignoring nonexistent directory "/usr/include/i486-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/4.2
 /usr/include/c++/4.2/i486-linux-gnu
 /usr/include/c++/4.2/backward
 /usr/local/include
 /usr/lib/gcc/i486-linux-gnu/4.2.1/include
 /usr/include
End of search list.
 /usr/lib/gcc/i486-linux-gnu/4.2.1/cc1plus -fpreprocessed test.ii -quiet
-dumpbase test.cc -mtune=generic -auxbase test -version -o test.s
GNU C++ version 4.2.1 (Debian 4.2.1-5) (i486-linux-gnu)
        compiled by GNU C version 4.2.1 (Debian 4.2.1-5).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 96235c4da4910435a4a1e0ded06ae124
/usr/include/c++/4.2/debug/functions.h: In function ‘bool
__gnu_debug::__check_partitioned(_ForwardIterator, _ForwardIterator, const
_Tp&, _Pred) [with _ForwardIterator = A*, _Tp = B, _Pred = bool (*)(B, A)]’:
/usr/include/c++/4.2/bits/stl_algo.h:3043:   instantiated from
‘_ForwardIterator std::upper_bound(_ForwardIterator, _ForwardIterator, const
_Tp&, _Compare) [with _ForwardIterator = A*, _Tp = B, _Compare = bool (*)(B,
A)]’
test.cc:9:   instantiated from here
/usr/include/c++/4.2/debug/functions.h:285: error: conversion from ‘A’ to
non-scalar type ‘B’ requested
/usr/include/c++/4.2/debug/functions.h:287: error: conversion from ‘A’ to
non-scalar type ‘B’ requested

Leo Moisio


-- 
           Summary: compilation inconsistency upper_bound vs lower_bound
                    with -D_GLIBCXX_DEBUG
           Product: gcc
           Version: 4.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: leo dot moisio at gmail dot com
 GCC build triplet: i486-pc-linux-gnu
  GCC host triplet: i486-pc-linux-gnu
GCC target triplet: i486-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33613


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-10-03  0:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-01 19:53 [Bug libstdc++/33613] New: compilation inconsistency upper_bound vs lower_bound with -D_GLIBCXX_DEBUG leo dot moisio at gmail dot com
2007-10-01 19:55 ` [Bug libstdc++/33613] " leo dot moisio at gmail dot com
2007-10-01 21:27 ` pcarlini at suse dot de
2007-10-02  9:17 ` pcarlini at suse dot de
2007-10-03  0:34 ` paolo at gcc dot gnu dot org
2007-10-03  0:35 ` 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).