public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/25306]  New: fill_n, generate_n assume Size is modifiable
@ 2005-12-08  2:41 sebor at roguewave dot com
  2005-12-08  3:36 ` [Bug libstdc++/25306] " gdr at integrable-solutions dot net
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: sebor at roguewave dot com @ 2005-12-08  2:41 UTC (permalink / raw)
  To: gcc-bugs

I came across this while gathering background for my post in c++std-lib-16112.
I thgought I might as well let you know in case you think it's important enough
to worry about (Size is only required to be convertible to an integral type
which doesn't mean it needs to have the predecrement operator defined). The
incorrect return type in this test case works around bug #25304.

$ cat t.cpp && g++ -c t.cpp
#include <algorithm>

struct Size {
    operator int() { return 0; }
private:
    void operator=(Size&);
};

template int* std::fill_n (int*, Size, const int&);
template int* std::generate_n (int*, Size, int (*)());

int main () { }

/usr/local/gcc-4.0.2/lib/gcc/sparc-sun-solaris2.9/4.0.2/../../../../include/c++/4.0.2/bits/stl_algo.h:
In function '_OutputIterator std::generate_n(_OutputIterator, _Size,
_Generator) [with _OutputIterator = int*, _Size = Size, _Generator = int
(*)()]':
t.cpp:10:   instantiated from here
/usr/local/gcc-4.0.2/lib/gcc/sparc-sun-solaris2.9/4.0.2/../../../../include/c++/4.0.2/bits/stl_algo.h:1003:
error: no match for 'operator--' in '--__n'
/usr/local/gcc-4.0.2/lib/gcc/sparc-sun-solaris2.9/4.0.2/../../../../include/c++/4.0.2/bits/stl_algobase.h:
In static member function 'static _OutputIterator
std::__fill_n<true>::fill_n(_OutputIterator, _Size, const _Tp&) [with
_OutputIterator = int*, _Size = Size, _Tp = int]':
/usr/local/gcc-4.0.2/lib/gcc/sparc-sun-solaris2.9/4.0.2/../../../../include/c++/4.0.2/bits/stl_algobase.h:642:
  instantiated from '_OutputIterator std::fill_n(_OutputIterator, _Size, const
_Tp&) [with _OutputIterator = int*, _Size = Size, _Tp = int]'
t.cpp:9:   instantiated from here
/usr/local/gcc-4.0.2/lib/gcc/sparc-sun-solaris2.9/4.0.2/../../../../include/c++/4.0.2/bits/stl_algobase.h:617:
error: no match for 'operator--' in '--__n'


-- 
           Summary: fill_n, generate_n assume Size is modifiable
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sebor at roguewave dot com
 GCC build triplet: all
  GCC host triplet: all
GCC target triplet: all


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


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

* [Bug libstdc++/25306] fill_n, generate_n assume Size is modifiable
  2005-12-08  2:41 [Bug libstdc++/25306] New: fill_n, generate_n assume Size is modifiable sebor at roguewave dot com
@ 2005-12-08  3:36 ` gdr at integrable-solutions dot net
  2006-01-10 10:37 ` chris at bubblescope dot net
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: gdr at integrable-solutions dot net @ 2005-12-08  3:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from gdr at integrable-solutions dot net  2005-12-08 03:36 -------
Subject: Re:   New: fill_n, generate_n assume Size is modifiable

"sebor at roguewave dot com" <gcc-bugzilla@gcc.gnu.org> writes:

| I came across this while gathering background for my post in
| c++std-lib-16112.  I thgought I might as well let you know in case
| you think it's important enough to worry about (Size is only
| required to be convertible to an integral type which doesn't mean it
| needs to have the predecrement operator defined). The incorrect
| return type in this test case works around bug #25304. 

I've come to take issue with the specification of Size.  It says it is
convertible to an integral type, does it does not say which.  I
believe the wording should be more precise -- yes, a library could
conservatively take long (long) or unsigned long (long), but still
that is a waste.  
Would you mind appending that issue to the one you raised in
c++std-lib-16112? 

-- gaby


-- 


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


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

* [Bug libstdc++/25306] fill_n, generate_n assume Size is modifiable
  2005-12-08  2:41 [Bug libstdc++/25306] New: fill_n, generate_n assume Size is modifiable sebor at roguewave dot com
  2005-12-08  3:36 ` [Bug libstdc++/25306] " gdr at integrable-solutions dot net
@ 2006-01-10 10:37 ` chris at bubblescope dot net
  2006-01-10 16:14 ` sebor at roguewave dot com
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: chris at bubblescope dot net @ 2006-01-10 10:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from chris at bubblescope dot net  2006-01-10 10:37 -------
I'm unclear on why it should be convertable to one of the built-in integral
types at all.. surely saying that
iterator_traits<_OutputIterator>::difference_type (where _OutputIterator is the
first parameter to the function) would make more sense?


-- 

chris at bubblescope dot net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |chris at bubblescope dot net


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



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

* [Bug libstdc++/25306] fill_n, generate_n assume Size is modifiable
  2005-12-08  2:41 [Bug libstdc++/25306] New: fill_n, generate_n assume Size is modifiable sebor at roguewave dot com
  2005-12-08  3:36 ` [Bug libstdc++/25306] " gdr at integrable-solutions dot net
  2006-01-10 10:37 ` chris at bubblescope dot net
@ 2006-01-10 16:14 ` sebor at roguewave dot com
  2006-01-10 17:00 ` chris at bubblescope dot net
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: sebor at roguewave dot com @ 2006-01-10 16:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from sebor at roguewave dot com  2006-01-10 16:14 -------
(In reply to comment #2)

I'm not sure what you mean. Could you show what one of the algorithms would
look like with a Size that's not convertible to an integer?


-- 


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



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

* [Bug libstdc++/25306] fill_n, generate_n assume Size is modifiable
  2005-12-08  2:41 [Bug libstdc++/25306] New: fill_n, generate_n assume Size is modifiable sebor at roguewave dot com
                   ` (2 preceding siblings ...)
  2006-01-10 16:14 ` sebor at roguewave dot com
@ 2006-01-10 17:00 ` chris at bubblescope dot net
  2006-01-10 17:13 ` gdr at cs dot tamu dot edu
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: chris at bubblescope dot net @ 2006-01-10 17:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from chris at bubblescope dot net  2006-01-10 17:00 -------
For the record, I was thinking of:

template<typename _OutputIterator, typename _Size, typename _Tp>
        _OutputIterator
        fill_n(_OutputIterator __first, _Size __n, const _Tp& __value)
        {
          iterator_traits<_OutputIterator>::difference_type __count(__n)
          for (; __count > 0; --__count, ++__first)
            *__first = __value;
          return __first;
        }

But now I've decided thats no good, as difference_type isn't designed for
OutputIterators. Sorry.


-- 


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



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

* [Bug libstdc++/25306] fill_n, generate_n assume Size is modifiable
  2005-12-08  2:41 [Bug libstdc++/25306] New: fill_n, generate_n assume Size is modifiable sebor at roguewave dot com
                   ` (3 preceding siblings ...)
  2006-01-10 17:00 ` chris at bubblescope dot net
@ 2006-01-10 17:13 ` gdr at cs dot tamu dot edu
  2006-02-26 10:10 ` pcarlini at suse dot de
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: gdr at cs dot tamu dot edu @ 2006-01-10 17:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from gdr at cs dot tamu dot edu  2006-01-10 17:13 -------
Subject: Re:  fill_n, generate_n assume Size is modifiable

"chris at bubblescope dot net" <gcc-bugzilla@gcc.gnu.org> writes:

| But now I've decided thats no good, as difference_type isn't designed for
| OutputIterators. 

Indeed; and that is arguably a bug in the standard specification.

-- Gaby


-- 


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



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

* [Bug libstdc++/25306] fill_n, generate_n assume Size is modifiable
  2005-12-08  2:41 [Bug libstdc++/25306] New: fill_n, generate_n assume Size is modifiable sebor at roguewave dot com
                   ` (4 preceding siblings ...)
  2006-01-10 17:13 ` gdr at cs dot tamu dot edu
@ 2006-02-26 10:10 ` pcarlini at suse dot de
  2006-02-26 11:01 ` pcarlini at suse dot de
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pcarlini at suse dot de @ 2006-02-26 10:10 UTC (permalink / raw)
  To: gcc-bugs



-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-02-26 10:09:47
               date|                            |


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


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

* [Bug libstdc++/25306] fill_n, generate_n assume Size is modifiable
  2005-12-08  2:41 [Bug libstdc++/25306] New: fill_n, generate_n assume Size is modifiable sebor at roguewave dot com
                   ` (5 preceding siblings ...)
  2006-02-26 10:10 ` pcarlini at suse dot de
@ 2006-02-26 11:01 ` pcarlini at suse dot de
  2010-05-21 15:29 ` paolo dot carlini at oracle dot com
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pcarlini at suse dot de @ 2006-02-26 11:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pcarlini at suse dot de  2006-02-26 10:10 -------
For now...


-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |SUSPENDED


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


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

* [Bug libstdc++/25306] fill_n, generate_n assume Size is modifiable
  2005-12-08  2:41 [Bug libstdc++/25306] New: fill_n, generate_n assume Size is modifiable sebor at roguewave dot com
                   ` (6 preceding siblings ...)
  2006-02-26 11:01 ` pcarlini at suse dot de
@ 2010-05-21 15:29 ` paolo dot carlini at oracle dot com
  2010-05-21 16:57 ` paolo at gcc dot gnu dot org
  2010-05-21 17:01 ` paolo dot carlini at oracle dot com
  9 siblings, 0 replies; 11+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-05-21 15:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from paolo dot carlini at oracle dot com  2010-05-21 15:29 -------
C++0x is not going to be much different here, thus let's fix the implementation
for now and be done with it.


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |paolo dot carlini at oracle
                   |dot org                     |dot com
             Status|SUSPENDED                   |ASSIGNED


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


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

* [Bug libstdc++/25306] fill_n, generate_n assume Size is modifiable
  2005-12-08  2:41 [Bug libstdc++/25306] New: fill_n, generate_n assume Size is modifiable sebor at roguewave dot com
                   ` (7 preceding siblings ...)
  2010-05-21 15:29 ` paolo dot carlini at oracle dot com
@ 2010-05-21 16:57 ` paolo at gcc dot gnu dot org
  2010-05-21 17:01 ` paolo dot carlini at oracle dot com
  9 siblings, 0 replies; 11+ messages in thread
From: paolo at gcc dot gnu dot org @ 2010-05-21 16:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from paolo at gcc dot gnu dot org  2010-05-21 16:57 -------
Subject: Bug 25306

Author: paolo
Date: Fri May 21 16:57:17 2010
New Revision: 159677

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=159677
Log:
2010-05-21  Paolo Carlini  <paolo.carlini@oracle.com>

        PR libstdc++/25306
        * include/bits/stl_algobase.h (fill_n): Use a properly typed __niter
        initialized to __n.
        * include/bits/stl_algo.h (generate_n): Likewise.
        * testsuite/25_algorithms/fill_n/25306.cc: New.
        * testsuite/25_algorithms/generate_n/25306.cc: Likewise.

Added:
    trunk/libstdc++-v3/testsuite/25_algorithms/fill_n/25306.cc
    trunk/libstdc++-v3/testsuite/25_algorithms/generate_n/25306.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/stl_algo.h
    trunk/libstdc++-v3/include/bits/stl_algobase.h


-- 


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


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

* [Bug libstdc++/25306] fill_n, generate_n assume Size is modifiable
  2005-12-08  2:41 [Bug libstdc++/25306] New: fill_n, generate_n assume Size is modifiable sebor at roguewave dot com
                   ` (8 preceding siblings ...)
  2010-05-21 16:57 ` paolo at gcc dot gnu dot org
@ 2010-05-21 17:01 ` paolo dot carlini at oracle dot com
  9 siblings, 0 replies; 11+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-05-21 17:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from paolo dot carlini at oracle dot com  2010-05-21 17:01 -------
Fixed for 4.6.0.


-- 

paolo dot carlini at oracle dot com changed:

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


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


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

end of thread, other threads:[~2010-05-21 17:01 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-08  2:41 [Bug libstdc++/25306] New: fill_n, generate_n assume Size is modifiable sebor at roguewave dot com
2005-12-08  3:36 ` [Bug libstdc++/25306] " gdr at integrable-solutions dot net
2006-01-10 10:37 ` chris at bubblescope dot net
2006-01-10 16:14 ` sebor at roguewave dot com
2006-01-10 17:00 ` chris at bubblescope dot net
2006-01-10 17:13 ` gdr at cs dot tamu dot edu
2006-02-26 10:10 ` pcarlini at suse dot de
2006-02-26 11:01 ` pcarlini at suse dot de
2010-05-21 15:29 ` paolo dot carlini at oracle dot com
2010-05-21 16:57 ` paolo at gcc dot gnu dot org
2010-05-21 17:01 ` paolo dot carlini at oracle dot com

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