From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19965 invoked by alias); 8 Jul 2005 18:26:06 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 19930 invoked by uid 22791); 8 Jul 2005 18:25:59 -0000 Received: from smtp17.wxs.nl (HELO smtp17.wxs.nl) (195.121.6.13) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Fri, 08 Jul 2005 18:25:59 +0000 Received: from brain.thuis (ip503d51d6.speed.planet.nl [80.61.81.214]) by smtp17.wxs.nl (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTP id <0IJB00GEVN727E@smtp17.wxs.nl> for gcc-help@gcc.gnu.org; Fri, 08 Jul 2005 20:25:51 +0200 (CEST) Date: Fri, 08 Jul 2005 18:26:00 -0000 From: Jeroen Wijnhout Subject: Re: copy ctor not called In-reply-to: <6.2.1.2.2.20050707070253.028b4e28@iplan-mn.corp.adobe.com> To: gcc-help@gcc.gnu.org Message-id: <200507082029.35954.Jeroen.Wijnhout@kdemail.net> MIME-version: 1.0 Content-type: multipart/mixed; boundary="Boundary_(ID_U8LeB8FbGNShnC6YDB8poQ)" User-Agent: KMail/1.8.50 References: <200507022024.10598.Jeroen.Wijnhout@kdemail.net> <6.2.1.2.2.20050705090751.0243dd68@iplan-mn.corp.adobe.com> <6.2.1.2.2.20050707070253.028b4e28@iplan-mn.corp.adobe.com> X-SW-Source: 2005-07/txt/msg00092.txt.bz2 --Boundary_(ID_U8LeB8FbGNShnC6YDB8poQ) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT Content-disposition: inline Content-length: 951 On Thursday 07 July 2005 02:04 pm, Eljay Love-Jensen wrote: > Hi Jeroen, > > >According to your statement they are wrong. > > Please re-read my statement. My statement does not contradict what you > cited from C++ Primer. > > What is being elided is the assignment operator, not the copy constructor. > The copy constructor is still being used for initialization. Glad to hear that you agree with C++ primer ;-). However, as I found out, the default behavior of gcc 3.3.4 is not to call the copy constructor in: Foo f = 2; instead it uses direct initialization. I've written a simple test program that shows this quite clearly. So here the default behavior of gcc contradicts with what I've read in C++ primer. The assigment operator is never called in the statement above, with or without -fno-elide-constructors. See the attached code for an example. best, Jeroen -- Kile -- KDE Integrated LaTeX Environment http://kile.sourceforge.net --Boundary_(ID_U8LeB8FbGNShnC6YDB8poQ) Content-type: application/x-tgz; name=CopyCtor.tar.gz Content-transfer-encoding: base64 Content-disposition: attachment; filename=CopyCtor.tar.gz Content-length: 993 H4sIAHvFzkIAA+1WbW/aMBDma/MrTiBNUEaXkBektEyaQNX6YepPQF7itN6C HSVOq63afvvOhoSk4qWTCtNUPx9wfDk/j8/nOzIT2Y+ZFPmHzvFgIya+r0Zn 4tt67nieHtfoOPY4cH1v7LtBx3bcwPc64B9xTzXKQpIcoPPIvvF7UcrdfjQv 9vBUgVTjf4JZlf8v5DtNWEqPoKHOI1jle2v+Pdep8z/2XMy/79p+B05yiG88 /yRNQ4hZTiP5UER4GVqTERc0ZTG1rKa1veAiyjK4FuLi3jq7Gw5hJHbzKd82 V6VwgDPhYqT9RpHghczLCO9s8VyrItuiGaWU8NA6y5cwypMXRPyvE3Mi1PWv T/s4Ggfq3wlcd9P/VQk5Hj6Z+j8FeizhMU1gcX17u/i8sHo4YZzWc6vHeJSW WFNXTGDhUbL8aFllwfgdcLKkRUYiCoWML1WNkaJQZWs9WQBZ+TVlUYhPoGz9 AYSwXMREkr490NYn/QvA6eNN3B9crqcRZgGurtCZxWrshmo9dPXzbFP+0J/T hJSpHOhXlMfpiuKXpYffWrWltJd6Tivm7XyKjnEJrBEJe6VI2FQbmX6zIx6l r7ufJnmX7JB+mTa2vcYGngnCOjyYQnKh4xy0dvIgkFNkNCe4drpnU3s38ako 2B1fUi7/Ul4lYWUGLd2SzKksc75maCzLcvZAJA1rhtqlaWHxZSPE9Zm2+HUo UygWeNnlTVzteDhsW9ZbxeYiWbRi3zj8QhFtwsMIw8qO7lNw8FUPj4Ilp/kH qvv/87/MV9Q49P3nBpvvP8+dYP+f2JPA9P9TYFt7r21d/VHQ3dXv1RVeEsZV V3wP0T2e4/n5QDf/qvC7c32tsACYZCRlP7EcBA9bBa86QuL0nVXvqlfqHnVw 3RhrZtxeOBecNhytuifYWHlv5bvOwMDAwMDAwMDAwMDAwMDAwMDAwMDAwODt 4g9hf3lAACgAAA== --Boundary_(ID_U8LeB8FbGNShnC6YDB8poQ)--