Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #13728 > unrolled thread

What would happen if your destructors aren't get called?

Started by"U.Mutlu" <for-usenet@mutluit.com>
First post2012-02-04 00:01 +0100
Last post2012-02-07 10:32 +0100
Articles 14 — 9 participants

Back to article view | Back to comp.lang.c++


Contents

  What would happen if your destructors aren't get called? "U.Mutlu" <for-usenet@mutluit.com> - 2012-02-04 00:01 +0100
    Re: What would happen if your destructors aren't get called? Ian Collins <ian-news@hotmail.com> - 2012-02-04 12:05 +1300
      Re: What would happen if your destructors aren't get called? "U.Mutlu" <for-usenet@mutluit.com> - 2012-02-04 00:23 +0100
        Re: What would happen if your destructors aren't get called? Ian Collins <ian-news@hotmail.com> - 2012-02-04 13:18 +1300
          Re: What would happen if your destructors aren't get called? "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2012-02-04 15:43 +0100
          Re: What would happen if your destructors aren't get called? "MikeWhy" <boat042-nospam@yahoo.com> - 2012-02-04 14:19 -0600
          Re: What would happen if your destructors aren't get called? Ian Collins <ian-news@hotmail.com> - 2012-02-05 09:37 +1300
        Re: What would happen if your destructors aren't get called? Goran <goran.pusic@gmail.com> - 2012-02-03 22:03 -0800
      Re: What would happen if your destructors aren't get called? Joshua Maurice <joshuamaurice@gmail.com> - 2012-02-03 15:11 -0800
        Re: What would happen if your destructors aren't get called? Ian Collins <ian-news@hotmail.com> - 2012-02-07 17:19 +1300
    Re: What would happen if your destructors aren't get         called? Sam <sam@email-scan.com> - 2012-02-03 17:28 -0600
    Re: What would happen if your destructors aren't get called? Paavo Helde <myfirstname@osa.pri.ee> - 2012-02-03 18:22 -0600
    Re: What would happen if your destructors aren't get called? "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2012-02-04 15:46 +0100
    Re: What would happen if your destructors aren't get called? "Gernot Frisch" <me@privacy.net> - 2012-02-07 10:32 +0100

#13728 — What would happen if your destructors aren't get called?

From"U.Mutlu" <for-usenet@mutluit.com>
Date2012-02-04 00:01 +0100
SubjectWhat would happen if your destructors aren't get called?
Message-ID<jghp01$ak1$1@speranza.aioe.org>
Can you imagine:
   What would happen if your destructors aren't get called?  :-)

Today I encountered a very subtile bug in Microsoft's VS2008:
in my case the destructor of a globally used class isn't called
if the implementation of the destructor is in the cpp-file
and it is part of a library project.
It gets called only when the dtor code is in the h-file!
Disabling optimization and intrinsic stuff all has no effect on this,
it's an unbelievable bug!

A research on the net revealed that this bug is known to Microsoft
since at least 4/1/2008 as this MS-page indicates:
   http://connect.microsoft.com/VisualStudio/feedback/details/336316
There a poster has written this:
"
Posted by Joshua Maurice on 3/16/2010 at 5:49 PM
  I am going to be pushing my company to not use the visual studios
  compiler suite and drop all MSDN licenses because of this
  incredibly broken compiler optimization. C++'s fundamental
  underpinning is the automatic calling of destructors of
  stack objects, member sub-objects, etc. This is the very first
  thing added to C to make C++, and it is the most important
  defining quality of C++, aka RAII. Because the compiler
  bungles such a basic case, and because you prioritize it
  so lowly makes me question whether or not visual studios is the
  appropriate place to spend our money for a quality product.

  Put another way, if we are unable to ship optimized builds
  without fear of memory leaks, then we're left with:
  1- Don't use RAII, or basically don't program using standard C++.
  2- Don't ship optimized builds.
  3- Ship broken builds.
  4- Don't use visual studios. Aka use gcc or some alternative.

  The only reason my company currently uses visual studios, and buys
  the MSDN licenses, is because it is a superior optimizing compiler.
  However, we will not use an optimizing compiler if it affects correctness.
  In our line of work, basically any coding besides games, correctness
  matters most. Thus, if our choices are the above, 1 is not practical
  due to time to market costs, 3 is not acceptable, and 4 is preferable
  to 2, because although visual studios might optimize better when it
  doesn't break cases, I bet gcc will optimize better vs visual studios
  with all the optimizations turned off, thus obviating the only reason
  to use visual studios over gcc.

  I suggest you seriously rethink your business strategy. No one will put up
  with a nonstandard C++ compiler which misses the entire point of C++.
"

It is interessting how Microsoft gives a very low priority to this unbelievable bug,
just see yourself the answers at the above link. Unbelievable!

How can Microsoft sell such a buggy product and call it "C++ compiler"?

[toc] | [next] | [standalone]


#13729

FromIan Collins <ian-news@hotmail.com>
Date2012-02-04 12:05 +1300
Message-ID<9p37i4Fjr2U1@mid.individual.net>
In reply to#13728
On 02/ 4/12 12:01 PM, U.Mutlu wrote:

<Snip OT rant>

> How can Microsoft sell such a buggy product and call it "C++ compiler"?

Show me a bug free compiler and I'll show you a flying pig.

-- 
Ian Collins

[toc] | [prev] | [next] | [standalone]


#13730

From"U.Mutlu" <for-usenet@mutluit.com>
Date2012-02-04 00:23 +0100
Message-ID<4F2C6C7D.4020500@mutluit.com>
In reply to#13729
Ian Collins wrote, On 02/04/12 00:05:
> On 02/ 4/12 12:01 PM, U.Mutlu wrote:
>
>> How can Microsoft sell such a buggy product and call it "C++ compiler"?
>
> Show me a bug free compiler and I'll show you a flying pig.

But if such elemantary parts like automatically called destructors
aren't working in a C++ compiler, then it can't be a C++ compiler.

Imagine what happens if that product is used in sensitive areas
like the NASA, airplane industry, defense companies etc. etc...

A C++ conformance body should control the vendors.

[toc] | [prev] | [next] | [standalone]


#13732

FromIan Collins <ian-news@hotmail.com>
Date2012-02-04 13:18 +1300
Message-ID<9p3breFjr2U2@mid.individual.net>
In reply to#13730
On 02/ 4/12 12:23 PM, U.Mutlu wrote:
> Ian Collins wrote, On 02/04/12 00:05:
>> On 02/ 4/12 12:01 PM, U.Mutlu wrote:
>>
>>> How can Microsoft sell such a buggy product and call it "C++ compiler"?
>>
>> Show me a bug free compiler and I'll show you a flying pig.
>
> But if such elemantary parts like automatically called destructors
> aren't working in a C++ compiler, then it can't be a C++ compiler.

Like any piece of commercial software, the bugs that get fixed are 
either the most embarrassing ones, or the ones the most paying customers 
prioritise.  There's no point in whinging about something you got for 
free, get a support contract and raise a bug.

> Imagine what happens if that product is used in sensitive areas
> like the NASA, airplane industry, defense companies etc. etc...

I doubt anyone runs windows in safety critical systems :)

> A C++ conformance body should control the vendors.

How?

-- 
Ian Collins

[toc] | [prev] | [next] | [standalone]


#13738

From"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>
Date2012-02-04 15:43 +0100
Message-ID<jgjg5k$fc3$1@dont-email.me>
In reply to#13732
On 04.02.2012 01:18, Ian Collins wrote:
>
> I doubt anyone runs windows in safety critical systems :)

http://en.wikipedia.org/wiki/USS_Yorktown_%28CG-48%29#Smart_ship_testbed

he he


cheers,

- Alf

[toc] | [prev] | [next] | [standalone]


#13743

From"MikeWhy" <boat042-nospam@yahoo.com>
Date2012-02-04 14:19 -0600
Message-ID<jgk3t9$3hu$1@dont-email.me>
In reply to#13732
"Stefan Ram" <ram@zedat.fu-berlin.de> wrote in message 
news:C++-20120204204129@ram.dialup.fu-berlin.de...
> Ian Collins <ian-news@hotmail.com> writes:
>>I doubt anyone runs windows in safety critical systems :)
>
>  See also
>
> http://en.wikipedia.org/wiki/SMCS#SMCS-NG_as_first_deployment_of_.22Windows_for_Warships.22

[... 'pro-UNIX' engineers felt that open source UNIX rather than Microsoft 
Windows should be used as the foundation of future naval command systems and 
circulated their concerns within the company.]

I don't see how this conversation can have a good ending.

[toc] | [prev] | [next] | [standalone]


#13744

FromIan Collins <ian-news@hotmail.com>
Date2012-02-05 09:37 +1300
Message-ID<9p5j8qF4ajU1@mid.individual.net>
In reply to#13732
On 02/ 5/12 08:41 AM, Stefan Ram wrote:
> Ian Collins<ian-news@hotmail.com>  writes:

>>> A C++ conformance body should control the vendors.
>> How?
>
>    When a supplier sells a product under the name »C++ compiler«,
>    and this is not a C++ compiler, the customer might be entitled
>    to some compensation in some countries?

Define "not a C++ compiler".

Unlike Ada, there isn't a standard validation procedure for C++.  If 
there was, C++ would probably have the same level of support and 
popularity as Ada.  Producing a validated compiler is an extremely 
expensive process, as is producing the validation suite.

-- 
Ian Collins

[toc] | [prev] | [next] | [standalone]


#13785

FromGoran <goran.pusic@gmail.com>
Date2012-02-03 22:03 -0800
Message-ID<e3073739-7da0-47d3-a595-946e8c3dad7c@a15g2000yqf.googlegroups.com>
In reply to#13730
On Feb 4, 12:23 am, "U.Mutlu" <for-use...@mutluit.com> wrote:
> Ian Collins wrote, On 02/04/12 00:05:
>
> > On 02/ 4/12 12:01 PM, U.Mutlu wrote:
>
> >> How can Microsoft sell such a buggy product and call it "C++ compiler"?
>
> > Show me a bug free compiler and I'll show you a flying pig.
>
> But if such elemantary parts like automatically called destructors
> aren't working in a C++ compiler, then it can't be a C++ compiler.
>
> Imagine what happens if that product is used in sensitive areas
> like the NASA, airplane industry, defense companies etc. etc...
>
> A C++ conformance body should control the vendors.

So far, you didn't show any evidence (except "I say so") that there
indeed is a problem. You only presume that you found relevant
"connect" issue, and your own post contradict that (removing
optimizations doesn't fix the problem in your case, whereas it does in
"connect"). Make a test case, otherwise you don't sound believable.

Libraries are wholly outside of C and C++ language scope. Therefore,
your conformance body would have nothing to stand on with this.

Finally, if you suspect --MS-- compiler bug, this is a wrong
newsgroup. You should try over at MS. Their newsgroups are decently
lively.

Goran.

[toc] | [prev] | [next] | [standalone]


#13783

FromJoshua Maurice <joshuamaurice@gmail.com>
Date2012-02-03 15:11 -0800
Message-ID<07c30d48-8bb0-405d-9fbc-02f11ef50855@3g2000pbd.googlegroups.com>
In reply to#13729
On Feb 3, 3:05 pm, Ian Collins <ian-n...@hotmail.com> wrote:
> On 02/ 4/12 12:01 PM, U.Mutlu wrote:
>
> <Snip OT rant>
>
> > How can Microsoft sell such a buggy product and call it "C++ compiler"?
>
> Show me a bug free compiler and I'll show you a flying pig.

Well, now that my name has been invoked, suppose I should say
something.

It doesn't seem like the cited bug with my description is your bug.
They sound like unrelated issues. Can you provide a minimal repro case
so we can verify it's a compiler bug?

[toc] | [prev] | [next] | [standalone]


#13786

FromIan Collins <ian-news@hotmail.com>
Date2012-02-07 17:19 +1300
Message-ID<9pbn2gFicgU4@mid.individual.net>
In reply to#13783
On 02/ 4/12 12:11 PM, Joshua Maurice wrote:
> On Feb 3, 3:05 pm, Ian Collins<ian-n...@hotmail.com>  wrote:
>> On 02/ 4/12 12:01 PM, U.Mutlu wrote:
>>
>> <Snip OT rant>
>>
>>> How can Microsoft sell such a buggy product and call it "C++ compiler"?
>>
>> Show me a bug free compiler and I'll show you a flying pig.
>
> Well, now that my name has been invoked, suppose I should say
> something.
>
> It doesn't seem like the cited bug with my description is your bug.
> They sound like unrelated issues. Can you provide a minimal repro case
> so we can verify it's a compiler bug?

Not me, I don't use windows...

-- 
Ian Collins

[toc] | [prev] | [next] | [standalone]


#13731 — Re: What would happen if your destructors aren't get called?

FromSam <sam@email-scan.com>
Date2012-02-03 17:28 -0600
SubjectRe: What would happen if your destructors aren't get called?
Message-ID<cone.1328311683.374301.8181.1000@monster.email-scan.com>
In reply to#13728

[Multipart message — attachments visible in raw view] — view raw

U.Mutlu writes:

> It is interessting how Microsoft gives a very low priority to this  
> unbelievable bug,
> just see yourself the answers at the above link. Unbelievable!
>
> How can Microsoft sell such a buggy product and call it "C++ compiler"?

Very easy answer: because people are willing to pay for it.

If people stop buying Microsoft products, then they won't be able to sell  
them. The End.

[toc] | [prev] | [next] | [standalone]


#13733

FromPaavo Helde <myfirstname@osa.pri.ee>
Date2012-02-03 18:22 -0600
Message-ID<Xns9FEF181715251myfirstnameosapriee@216.196.109.131>
In reply to#13728
"U.Mutlu" <for-usenet@mutluit.com> wrote in
news:jghp01$ak1$1@speranza.aioe.org: 

> Can you imagine:
>    What would happen if your destructors aren't get called?  :-)
> 
> Today I encountered a very subtile bug in Microsoft's VS2008:
> in my case the destructor of a globally used class isn't called
> if the implementation of the destructor is in the cpp-file
> and it is part of a library project.
> It gets called only when the dtor code is in the h-file!
> Disabling optimization and intrinsic stuff all has no effect on this,
> it's an unbelievable bug!
> 
> A research on the net revealed that this bug is known to Microsoft
> since at least 4/1/2008 as this MS-page indicates:
>    http://connect.microsoft.com/VisualStudio/feedback/details/336316

336316 is an optimizer bug; if your bug does not go away when disabling 
optimization then this is most probably a different problem (and not 
necessarily a compiler bug, you do not give enough details). 

> 
> How can Microsoft sell such a buggy product and call it "C++
> compiler"? 

Programming is an engineering discipline - you work with what you have 
got, and take any necessary steps to provide a satisfactory solution. For 
example, there is a workaround (an extra unneeded return statement) 
present in our codebase for bug 336316 for several years already.

cheers
Paavo

[toc] | [prev] | [next] | [standalone]


#13739

From"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>
Date2012-02-04 15:46 +0100
Message-ID<jgjgbh$hn8$1@dont-email.me>
In reply to#13728
On 04.02.2012 00:01, U.Mutlu wrote:
> Can you imagine:
> What would happen if your destructors aren't get called? :-)
>
> Today I encountered a very subtile bug in Microsoft's VS2008:
> in my case the destructor of a globally used class isn't called
> if the implementation of the destructor is in the cpp-file
> and it is part of a library project.
> It gets called only when the dtor code is in the h-file!
> Disabling optimization and intrinsic stuff all has no effect on this,
> it's an unbelievable bug!
>
> A research on the net revealed that this bug is known to Microsoft
> since at least 4/1/2008 as this MS-page indicates:
> http://connect.microsoft.com/VisualStudio/feedback/details/336316
> There a poster has written this:
[snip]
>
> It is interessting how Microsoft gives a very low priority to this
> unbelievable bug,
> just see yourself the answers at the above link. Unbelievable!
>
> How can Microsoft sell such a buggy product and call it "C++ compiler"?

If you'd care to *read* what you linked you'd see that this bug has been 
fixed.

So your premises are wrong.

The main problem is that a very similar bug is real and has as far as I 
know, is not the same bug and has not been fixed. James Kanze and Herb 
Sutter discussed that in this group one or two years ago. Readers should 
not confuse your complain here, with that bug.


Cheers & hth.,

- Alf

[toc] | [prev] | [next] | [standalone]


#13813

From"Gernot Frisch" <me@privacy.net>
Date2012-02-07 10:32 +0100
Message-ID<9pc9dhFh4pU1@mid.individual.net>
In reply to#13728
> in my case the destructor of a globally used class isn't called

I had lots of problems with global objects, because their c'tors are called 
even before the CRT was initialized and so on. Also, the memory leak tools 
usually don't get them right.

So, I switched from using global objects to somehting like:
object& global_object()
{
    static object o;
return o;
}

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.c++


csiph-web