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

* [Bug libstdc++/33613] compilation inconsistency upper_bound vs lower_bound with -D_GLIBCXX_DEBUG
  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 ` leo dot moisio at gmail dot com
  2007-10-01 21:27 ` pcarlini at suse dot de
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: leo dot moisio at gmail dot com @ 2007-10-01 19:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from leo dot moisio at gmail dot com  2007-10-01 19:55 -------
Created an attachment (id=14281)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14281&action=view)
The preprocessed source as created by g++ -v -save-temps -D_GLIBCXX_DEBUG
test.cc


-- 


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


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

* [Bug libstdc++/33613] compilation inconsistency upper_bound vs lower_bound with -D_GLIBCXX_DEBUG
  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
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pcarlini at suse dot de @ 2007-10-01 21:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pcarlini at suse dot de  2007-10-01 21:26 -------
Yes. In short, the debug-mode checks must implement the detailed requirements
of DR270.

  http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#270

In practice, probably we need a dual version of __check_partitioned using
__pred(__value, *__first)


-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-10-01 21:26:52
               date|                            |


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


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

* [Bug libstdc++/33613] compilation inconsistency upper_bound vs lower_bound with -D_GLIBCXX_DEBUG
  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
  4 siblings, 0 replies; 6+ messages in thread
From: pcarlini at suse dot de @ 2007-10-02  9:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pcarlini at suse dot de  2007-10-02 09:17 -------
On it.


-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pcarlini at suse dot de
                   |dot org                     |
             Status|NEW                         |ASSIGNED


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


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

* [Bug libstdc++/33613] compilation inconsistency upper_bound vs lower_bound with -D_GLIBCXX_DEBUG
  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
                   ` (2 preceding siblings ...)
  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
  4 siblings, 0 replies; 6+ messages in thread
From: paolo at gcc dot gnu dot org @ 2007-10-03  0:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from paolo at gcc dot gnu dot org  2007-10-03 00:34 -------
Subject: Bug 33613

Author: paolo
Date: Wed Oct  3 00:34:40 2007
New Revision: 128974

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128974
Log:
2007-10-03  Paolo Carlini  <pcarlini@suse.de>

        PR libstdc++/33613
        * include/debug/functions.h (__check_partitioned): Rename to...
        (__check_partioned_lower): ... this.
        (__check_partioned_upper): Add.
        * include/debug/macros.h (__glibcxx_check_partitioned): Rename to...
        (__glibcxx_check_partitioned_lower): ... this, adjust.
        (__glibcxx_check_partitioned_upper): Add.
        * include/debug/debug.h (__glibcxx_requires_partitioned): Rename to...
        (__glibcxx_requires_partitioned_lower): ... this, adjust.
        (__glibcxx_requires_partitioned_upper): Add.
        * include/bits/stl_algo.h (lower_bound, upper_bound, equal_range,
        binary search): Use the above.
        * testsuite/25_algorithms/lower_bound/33613.cc: New.
        * testsuite/25_algorithms/upper_bound/33613.cc: Likewise.

Added:
    trunk/libstdc++-v3/testsuite/25_algorithms/lower_bound/33613.cc
    trunk/libstdc++-v3/testsuite/25_algorithms/upper_bound/33613.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/stl_algo.h
    trunk/libstdc++-v3/include/debug/debug.h
    trunk/libstdc++-v3/include/debug/functions.h
    trunk/libstdc++-v3/include/debug/macros.h


-- 


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


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

* [Bug libstdc++/33613] compilation inconsistency upper_bound vs lower_bound with -D_GLIBCXX_DEBUG
  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
                   ` (3 preceding siblings ...)
  2007-10-03  0:34 ` paolo at gcc dot gnu dot org
@ 2007-10-03  0:35 ` pcarlini at suse dot de
  4 siblings, 0 replies; 6+ messages in thread
From: pcarlini at suse dot de @ 2007-10-03  0:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pcarlini at suse dot de  2007-10-03 00:35 -------
Fixed for 4.3.0.


-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.3.0


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).