[fdo-internals] dynamic_cast and shared libraries on Linux

Traian Stanev traian.stanev at autodesk.com
Tue Feb 20 13:03:02 EST 2007

Yeah I've seen this problem and I think others have also. We just use
static casts.


-----Original Message-----
From: fdo-internals-bounces at lists.osgeo.org
[mailto:fdo-internals-bounces at lists.osgeo.org] On Behalf Of Frank
Warmerdam (External)
Sent: Tuesday, February 20, 2007 12:43 PM
To: FDO Internals Mail List
Subject: [fdo-internals] dynamic_cast and shared libraries on Linux


In the GDAL unit tests I am seeing some dynamic_cast failures that are
quite frustrating.

In particular this error:

  7) test: 17RfpTestBandConfig.testGetNullValue1 (F) line: 32

      "Unhandled FdoException? in testGetNullValue1"

  Seems to be due to this dynamic_cast failing:
          FdoPtr<FdoISelect> cmdSelect = dynamic_cast<FdoISelect*>(cmd);

  cmd is in fact suitable to dynamically cast to FdoISelect, but the
  class is related to FdoISelect somewhat indirectly (through several
  of dirivation and use of a template).  According to the following FAQ
  can result in problems with dynamic cast operating across shared
  boundaries with gcc 3.x (or later?):


  Changing the code to a static_cast resolves the issue.  I wonder if we
  need to require a particular version of gcc, or perhaps that we need
  to pursue some of the build options mentioned in the FAQ (which are a
  bit esoteric).  I did quickly try changing the dlopen() in
  FdoConnectionManagerto use the _GLOBAL flag but that did not seem to
  have an effect.

Has anyone else observed this sort of problem?  Are the GDAL unit tests
passing for anyone out there on linux?  If so, what version of gcc
are you using?

For the time being I'm changing the unit tests to use static_cast on
but this puts application code that uses dynamic_cast in substantial

Best regards,
I set the clouds in motion - turn up   | Frank Warmerdam,
warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo,

fdo-internals mailing list
fdo-internals at lists.osgeo.org

More information about the fdo-internals mailing list