swig generated code can not be compiled when option -nortti is used and %feature("director") is enabled for a c++ class

Bug #210898 reported by Andreas Oberritter
2
Affects Status Importance Assigned to Milestone
swig1.3 (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Binary package hint: swig1.3

Package: 1.3.33-2ubuntu1 (Ubuntu hardy)
Target language: Python

Swig provides the option -nortti to be used in conjunction with C++ code, which is compiled with -fno-rtti. This takes effect only if "directors" are used. It defines SWIG_DIRECTOR_NORTTI.

From the swig source code (Source/Modules/python.cxx):

#ifdef SWIG_DIRECTOR_NORTTI
/*
   When we don't use the native C++ RTTI, we implement a minimal one
   only for Directors.
*/

[...]

# define SWIG_DIRECTOR_CAST(Arg) Swig::get_rtdir(static_cast<void*>(Arg))
# define SWIG_DIRECTOR_RGTR(Arg1, Arg2) Swig::set_rtdir(static_cast<void*>(Arg1), Arg2)

#else

# define SWIG_DIRECTOR_CAST(Arg) dynamic_cast<Swig::Director*>(Arg)
# define SWIG_DIRECTOR_RGTR(Arg1, Arg2)

#endif /* SWIG_DIRECTOR_NORTTI */

The reason is that dynamic_cast<> must not be used with -fno-rtti. However, swig doesn't use the preprocessor macro defined above in one case, namely in Language::classDirectorDisown() (file: Source/Modules/lang.cxx).

You can work around this problem by applying the attached patch to swig, probably breaking other target languages.

Tags: patch
Revision history for this message
Andreas Oberritter (mtdcr) wrote :
Revision history for this message
Daniel T Chen (crimsun) wrote :

Is this symptom still reproducible in 8.10 or 9.04?

Changed in swig1.3:
status: New → Incomplete
Revision history for this message
Pedro Villavicencio (pedro) wrote :

We are closing this bug report because it lacks the information we need to investigate the problem, as described in the previous comments. Please reopen it if you can give us the missing information, and don't hesitate to submit bug reports in the future. To reopen the bug report you can click on the current status, under the Status column, and change the Status back to New. Thanks again!.

Changed in swig1.3:
status: Incomplete → Invalid
Revision history for this message
William Fulton (william-fultondesigns) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.