public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/10529: C++ front-end troubles with uninitialized_fill_n
@ 2003-04-28 22:46 bangerth
  0 siblings, 0 replies; 2+ messages in thread
From: bangerth @ 2003-04-28 22:46 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, jkanze, nobody, pcarlini

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


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

* c++/10529: C++ front-end troubles with uninitialized_fill_n
@ 2003-04-28 22:16 pcarlini
  0 siblings, 0 replies; 2+ messages in thread
From: pcarlini @ 2003-04-28 22:16 UTC (permalink / raw)
  To: gcc-gnats; +Cc: jkanze


>Number:         10529
>Category:       c++
>Synopsis:       C++ front-end troubles with uninitialized_fill_n
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Apr 28 22:16:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Paolo Carlini
>Release:        3.2.3, 3.3 pre, 3.4 exp
>Organization:
>Environment:
i686-pc-linux-gnu
>Description:
The compiler fails to compile the attached legal code.
paolo:~> g++ ccelide.cc
ccelide.cc: In function `void std::_Construct(_T1*, const _T2&) [with _T1 =
   Track, _T2 = Track]':
/usr/local/gcc-exp/include/c++/3.4/bits/stl_uninitialized.h:191:   instantiated from `_ForwardIter std::__uninitialized_fill_n_aux(_ForwardIter, _Size, const _Tp&, __false_type) [with _ForwardIter = Track*, _Size = int, _Tp = Track]'
/usr/local/gcc-exp/include/c++/3.4/bits/stl_uninitialized.h:216:   instantiated from `_ForwardIter std::uninitialized_fill_n(_ForwardIter, _Size, const _Tp&) [with _ForwardIter = Track*, _Size = int, _Tp = Track]'
ccelide.cc:26:   instantiated from here
ccelide.cc:11: error: `Track::Track(const Track&)' is private
/usr/local/gcc-exp/include/c++/3.4/bits/stl_construct.h:78: error: within this
   context
>How-To-Repeat:
Seems that the C++ frontend is involved: Comeau together
with libcomo compiles just fine the testcase and it has the
_same_ code (SGI/HP derivation) for uninitialized_fill_n of
current libstdc++-v3.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="ccelide.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="ccelide.cc"

CiNpbmNsdWRlIDxvc3RyZWFtPgojaW5jbHVkZSA8aW9zdHJlYW0+CiNpbmNsdWRlIDxtZW1vcnk+
CgpjbGFzcyBUcmFjawp7CnB1YmxpYzoKICAgIFRyYWNrKCBpbnQgaSApIDsKcHJpdmF0ZToKICAg
IFRyYWNrKCBUcmFjayBjb25zdCYgb3RoZXIgKSA7Cgpwcml2YXRlOgogICAgaW50ICAgICAgICAg
ICAgICAgICBteUkgOwp9IDsKClRyYWNrOjpUcmFjayggaW50IGkgKQogICAgOiAgIG15SSggaSAp
CnsKfQoKaW50Cm1haW4oKQp7CiAgICBUcmFjayogICAgICAgICAgICAgIG1lbSA9IChUcmFjayop
OjpvcGVyYXRvciBuZXcoIDMgKiBzaXplb2YoIFRyYWNrICkgKSA7CiAgICBzdGQ6OnVuaW5pdGlh
bGl6ZWRfZmlsbF9uKCBtZW0sIDMsIFRyYWNrKCAyICkgKSA7CiAgICBmb3IgKCBpbnQgaSA9IDAg
OyBpIDwgMyA7ICsrIGkgKSB7CiAgICAgICAgbWVtWyBpIF0uflRyYWNrKCkgOwogICAgfQogICAg
OjpvcGVyYXRvciBkZWxldGUoIG1lbSApIDsKICAgIHJldHVybiAwIDsKfQo=


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

end of thread, other threads:[~2003-04-28 22:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-28 22:46 c++/10529: C++ front-end troubles with uninitialized_fill_n bangerth
  -- strict thread matches above, loose matches on Subject: below --
2003-04-28 22:16 pcarlini

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