c++/10529: C++ front-end troubles with uninitialized_fill_n
bangerth@dealii.org
bangerth@dealii.org
Mon Apr 28 22:46:00 GMT 2003
Synopsis: C++ front-end troubles with uninitialized_fill_n
State-Changed-From-To: open->feedback
State-Changed-By: bangerth
State-Changed-When: Mon Apr 28 22:46:40 2003
State-Changed-Why:
Hm, I'm not sure I understand what is going on. Your code
reduces to this:
-----------------------
#include <memory>
class X {
public:
X(int i);
private:
X(const X&);
};
int main() {
std::uninitialized_fill_n( (X*)0, 3, X(2) ) ;
}
-------------------------
which indeed fails to compile since X has no public copy
constructor. However, the draft standard has this wording:
20.4.4.3 uninitialized_fill_n [lib.uninitialized.fill.n]
template <class ForwardIterator, class Size, class T>
void uninitialized_fill_n(ForwardIterator first, Size n, const T& x);
Effects:
while (n--)
new (static_cast<void*>(&*result++))
typename iterator_traits<ForwardIterator>::value_type(*first++);
So it uses placement new to generate a -- well, that
seems like a defect, but if we take the respective
statement from right above that place (unitialized_fill),
it reads
new (static_cast<void*>(&*first++))
typename iterator_traits<ForwardIterator>::value_type(x);
So that would make a copy of x, no? I would say that then
we need a public copy constructor. What am I missing?
W.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10529
More information about the Gcc-prs
mailing list