Sunday, September 25, 2016

Digest for comp.lang.c++@googlegroups.com - 10 updates in 1 topic

Michael Kilburn <crusader.mike@gmail.com>: Sep 24 04:28PM -0700

On Saturday, September 24, 2016 at 1:12:37 PM UTC-5, Paavo Helde wrote:
> cost). If you put some content in G1, G2, e.g. another class object with
> printouts in ctor, dtor, copy ctor, move ctor, then the behavior goes
> back to the previous (less objects created-destroyed).
 
Try adding POD class members -- regardless how big they are compiler will still create new copies. Basically, anything that changes class to non-POD "fixes" the issue.
 

> here, define proper move (rvalue) constructors for your classes. Relying
> on the compiler to optimize the copies away is not guaranteed (though
> might probably work in simple scenarios).
 
I don't think it is about optimizations... In f(g()) expression of g's return type is exact match of f's argument type -- I expect no additional copies (it simply doesn't make any sense -- why create a copy of a temporary if g already created a temporary we need?).
 
 
> call for each object. All objects other than F are destroyed before the
> semicolon is reached in the first line of main. What do you think is
> wrong here?
 
Order is wrong. Everywhere. "G2 g2(H21, H22) { return G2(); }" means that soon after G2' ctor we are supposed to get H21 and H22 dtor calls (because we leave g2's scope). Same for every function call in this example.
woodbrian77@gmail.com: Sep 24 06:05PM -0700

On Saturday, September 24, 2016 at 6:10:08 PM UTC-5, Chris Vine wrote:
> Religious nutjobs like you and Rick, who can't control themselves and
> have no concern for the supposed topic of this newsgroup are in danger
> of making it unusable for serious discussion of C++.
 
I see a difference between Rick and myself. He often starts
threads that are not about C++. If he did it a few times a
year it wouldn't be so bad, but he's doing it on a weekly
basis if not more so.
 
I just let people know that the blessings I have (starting
a company, using C++ heavily in the company, focusing on on-line
code generation, etc.) are from G-d.
 
> At least the nonsense that Rick and you come up with wouldn't get past
> the moderator on c.l.c++.m.
 
I don't read a lot of what Rick writes here. What I have
read, I sometimes agree with him, but not always.
 
> You comment on this above is bizarre enough as it stands. But holding
> out the :: prefix as an attribute of a "royal priesthood" as in your
> recent post?
 
I believe that.
 
> Please... you are raving.
 
Let's see. I foresaw the ongoing financial collapses and
realized the need to start a company. I stuck with C++ when
some thought it was dying. I've worked on an on line approach
that has many advantages over things like the serialization
library in Boost, Protocol Buffers, etc. As far as I can tell
I'm like Ben Shapiro -- http://dailywire.com -- an example of
American exceptionalism -- blessed because of my faith.
 
Brian
Ebenezer Enterprises
http://webEbenezer.net
"Chris M. Thomasson" <invalid@invalid.invalid>: Sep 24 07:57PM -0700

On 9/24/2016 6:05 PM, woodbrian77@gmail.com wrote:
[...] As far as I can tell
> I'm like Ben Shapiro -- http://dailywire.com -- an example of
> American exceptionalism -- blessed because of my faith.
 
What does this actually mean?
Ian Collins <ian-news@hotmail.com>: Sep 25 04:02PM +1300

On 09/25/16 03:57 PM, Chris M. Thomasson wrote:
>> I'm like Ben Shapiro -- http://dailywire.com -- an example of
>> American exceptionalism -- blessed because of my faith.
 
> What does this actually mean?
 
Delusions of grandeur?
 
--
Ian
"Chris M. Thomasson" <invalid@invalid.invalid>: Sep 24 08:37PM -0700

On 9/24/2016 8:02 PM, Ian Collins wrote:
>>> American exceptionalism -- blessed because of my faith.
 
>> What does this actually mean?
 
> Delusions of grandeur?
 
Yikes! I hope this type of grandeur is not as extreme as the Black
Knight in MP...
 
https://youtu.be/mjEcj8KpuJw
 
;^)
Paavo Helde <myfirstname@osa.pri.ee>: Sep 25 11:51AM +0300

On 25.09.2016 2:28, Michael Kilburn wrote:
>> printouts in ctor, dtor, copy ctor, move ctor, then the behavior goes
>> back to the previous (less objects created-destroyed).
 
> Try adding POD class members -- regardless how big they are compiler will still create new copies. Basically, anything that changes class to non-POD "fixes" the issue.
 
Then maybe this is a quality-of-implementation issue of the Microsoft
compiler? Maybe they are trying to keep some backward-compatibility
behavior for old legacy C programs?
 
>> on the compiler to optimize the copies away is not guaranteed (though
>> might probably work in simple scenarios).
 
> I don't think it is about optimizations... In f(g()) expression of g's return type is exact match of f's argument type -- I expect no additional copies (it simply doesn't make any sense -- why create a copy of a temporary if g already created a temporary we need?).
 
What one expects does not change the reality :-) ... unfortunately. And
the reality is that such optimizations are not mandated and apparently
not universally supported.
 
>> semicolon is reached in the first line of main. What do you think is
>> wrong here?
 
> Order is wrong. Everywhere. "G2 g2(H21, H22) { return G2(); }" means that soon after G2' ctor we are supposed to get H21 and H22 dtor calls (because we leave g2's scope). Same for every function call in this example.
 
The C++ standard does not contain any such phrase like "soon after". The
order of any operations between sequence points is not fixed, so an
implementation can do them in whatever order they like. The standard
just requires that all the operations must be completed before the next
sequence point, which in this case is the semicolon in the end of the
first line of main().
 
If you look at the gcc output then you see that it destructs objects in
the exact opposite order of construction, which actually makes a lot of
sense.
 
Cheers
Paavo
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Sep 25 03:51PM +0200

On 25.09.2016 10:51, Paavo Helde wrote:
 
> If you look at the gcc output then you see that it destructs objects in
> the exact opposite order of construction, which actually makes a lot of
> sense.
 
 
C++11 §12.2/5:
 
"The destruction of a temporary whose lifetime is not extended by being
bound to a reference is sequenced before the destruction of every
temporary which is constructed earlier in the same full-expression"
 
 
Cheers!,
 
- Alf
(Oh, it's Sunday)
Paavo Helde <myfirstname@osa.pri.ee>: Sep 25 05:49PM +0300

On 25.09.2016 16:51, Alf P. Steinbach wrote:
 
> "The destruction of a temporary whose lifetime is not extended by being
> bound to a reference is sequenced before the destruction of every
> temporary which is constructed earlier in the same full-expression"
 
Thanks for pointing this out! Does this mean that MSVC is just
non-conforming in this regard?
 
Cheers
Paavo
Jerry Stuckle <jstucklex@attglobal.net>: Sep 25 11:58AM -0400

On 9/25/2016 9:51 AM, Alf P. Steinbach wrote:
 
> Cheers!,
 
> - Alf
> (Oh, it's Sunday)
 
But it doesn't say what the order of construction is. Just that
temporaries are destructed in the reverse order of construction - as
Paavo said.
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
scott@slp53.sl.home (Scott Lurndal): Sep 25 04:12PM

>>> American exceptionalism -- blessed because of my faith.
 
>> What does this actually mean?
 
>Delusions of grandeur?
 
No, just simple insanity.
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: