From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24104 invoked by alias); 1 Oct 2007 19:53:43 -0000 Received: (qmail 24072 invoked by uid 48); 1 Oct 2007 19:53:31 -0000 Date: Mon, 01 Oct 2007 19:53:00 -0000 Subject: [Bug libstdc++/33613] New: compilation inconsistency upper_bound vs lower_bound with -D_GLIBCXX_DEBUG X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "leo dot moisio at gmail dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-10/txt/msg00067.txt.bz2 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 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