Re: semantics of attribute const on constructors

2011-02-25 Thread Matthias Kretz
Hi, On Friday 25 February 2011 19:37:27 Jonathan Wakely wrote: > On 25 February 2011 17:05, Matthias Kretz wrote: > > I'm saying that the way I thought about const + ctor seems logical (if > > you are not a compiler developer at least :-) ). Regardless of how well > > defined "return value" is in

Re: semantics of attribute const on constructors

2011-02-25 Thread Jonathan Wakely
On 25 February 2011 17:05, Matthias Kretz wrote: > > I'm saying that the way I thought about const + ctor seems logical (if you are > not a compiler developer at least :-) ). Regardless of how well defined > "return value" is in the standards, to me as C++ developer the ctor acts as a > function th

Re: semantics of attribute const on constructors

2011-02-25 Thread Matthias Kretz
Hi, I don't generally disagree, that GCC does the correct thing here. I'm completely satisfied if you don't change GCC. I'm saying that the way I thought about const + ctor seems logical (if you are not a compiler developer at least :-) ). Regardless of how well defined "return value" is in th

Re: semantics of attribute const on constructors

2011-02-25 Thread Dave Korn
On 25/02/2011 15:43, Matthias Kretz wrote: > I fully understand why it happened. So I imply your answer is that ctors do > not have a return value and my expectation, as explained above, is wrong. You'd already know if ctors had return values, because you'd have had to be writing return statem

Re: semantics of attribute const on constructors

2011-02-25 Thread David Brown
On 25/02/2011 16:43, Matthias Kretz wrote: Hi, On Friday 25 February 2011 16:26:24 Richard Guenther wrote: On Fri, Feb 25, 2011 at 4:19 PM, Matthias Kretz wrote: My expectation was, that, since the ctor has a constructed object as return value, the compiler is free, instead of calling a ctor t

Re: semantics of attribute const on constructors

2011-02-25 Thread Matthias Kretz
Hi, On Friday 25 February 2011 16:26:24 Richard Guenther wrote: > On Fri, Feb 25, 2011 at 4:19 PM, Matthias Kretz wrote: > > My expectation was, that, since the ctor has a constructed object as > > return value, the compiler is free, instead of calling a ctor twice for > > the case of e.g. > > Foo

Re: semantics of attribute const on constructors

2011-02-25 Thread Richard Guenther
On Fri, Feb 25, 2011 at 4:19 PM, Matthias Kretz wrote: > Hi, > > what are the exact semantics of __attribute__((const)), when attached to a C++ > class constructor, supposed to be? > > My expectation was, that, since the ctor has a constructed object as return > value, the compiler is free, instea

semantics of attribute const on constructors

2011-02-25 Thread Matthias Kretz
Hi, what are the exact semantics of __attribute__((const)), when attached to a C++ class constructor, supposed to be? My expectation was, that, since the ctor has a constructed object as return value, the compiler is free, instead of calling a ctor twice for the case of e.g. Foo a(1); Foo b(1)