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


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

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

From "U.Mutlu" <for-usenet@mutluit.com>
Newsgroups comp.lang.c++
Subject What would happen if your destructors aren't get called?
Date 2012-02-04 00:01 +0100
Organization mutluit.com
Message-ID <jghp01$ak1$1@speranza.aioe.org> (permalink)

Show all headers | View raw


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"?

Back to comp.lang.c++ | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

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

csiph-web