#105 __Named_exception needs to be conditionally inlined

open-invalid
nobody
5
2010-04-05
2010-04-05
Nigel Stewart
No

The rationale ought to be reasonably clear from the diff.

I was observing link errors due to __Named_exception symbols in multiple .o files.
I'd be happy to provide more specific details as needed.

67a68,73
> # if defined (_STLP_USE_NO_IOSTREAMS) && !defined (__BUILDING_STLPORT)
> # define _STLP_NAMED_EXCEPTION_INLINE inline
> # else
> # define _STLP_NAMED_EXCEPTION_INLINE
> # endif
>
70,72c76,78
< __Named_exception(const string& __str);
< __Named_exception(const __Named_exception&);
< __Named_exception& operator = (const __Named_exception&);
---
> _STLP_NAMED_EXCEPTION_INLINE __Named_exception(const string& __str);
> _STLP_NAMED_EXCEPTION_INLINE __Named_exception(const __Named_exception&);
> _STLP_NAMED_EXCEPTION_INLINE __Named_exception& operator = (const __Named_exception&);
74,75c80,81
< const char* what() const _STLP_NOTHROW_INHERENTLY;
< ~__Named_exception() _STLP_NOTHROW_INHERENTLY;
---
> _STLP_NAMED_EXCEPTION_INLINE const char* what() const _STLP_NOTHROW_INHERENTLY;
> _STLP_NAMED_EXCEPTION_INLINE ~__Named_exception() _STLP_NOTHROW_INHERENTLY;

Discussion

  • If it really bug description, it is the sample of misterious description. Please, read http://stlport.sourceforge.net/BugReport.shtml (and, please, pay special attention for three references at the page's bottom).

     
    • status: open --> open-invalid
     
  • Nigel Stewart
    Nigel Stewart
    2010-04-05

    Which is the most convenient compiler for you to repro this? VC9? Linux gcc?

     
  • Nigel Stewart
    Nigel Stewart
    2010-04-10

    The problem here is due to __Named_exception being non-templated and the member functions being defined via the include of the corresponding .cpp in the .h file. Each compilation unit that #includes this has the symbols for the __Named_exception member functions, resulting in a link error.

    So the idea of the patch is to conditionally inline the __Named_exception in the same circumstances that the .cpp is included.

    Most likely I came across on OSX Leopard with XCode 3.14 with gcc 4.0.1 Our project builds with _STLP_USE_NO_IOSTREAMS and we doesn't link with an STLPort library, since it doesn't need to.
    I'd fully expect to see the same issue on other platforms too.

    The full set of STLPort compile flags used as follows:

    STLPORT_INCLUDES += [...] /STLport-5.2.1/stlport
    STLPORT_CXXFLAGS += -D_STLP_DONT_USE_AUTO_LINK=1
    STLPORT_CXXFLAGS += -D_STLP_NO_IOSTREAMS=1
    STLPORT_CXXFLAGS += -D_STLP_DONT_USE_EXCEPTIONS=1
    STLPORT_CXXFLAGS += -D_STLP_USE_PTR_SPECIALIZATIONS=1
    STLPORT_CXXFLAGS += -D_STLP_NO_TYPEINFO=1
    STLPORT_CXXFLAGS += -D_STLP_USE_MALLOC=1