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

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