[Pkg-octave-devel] Bug#302688: octaviz: FTBFS (amd64/gcc-4.0): cast from 'vtkObjectBase*' to 'unsigned int' loses precision

Andreas Jochens Andreas Jochens <aj@andaco.de>, 302688@bugs.debian.org
Sat, 02 Apr 2005 13:16:46 +0200


Package: octaviz
Version: 0.4.0-10
Severity: normal
Tags: patch

When building 'octaviz' on amd64/unstable with gcc-4.0,
I get the following error:

make[4]: Entering directory `/octaviz-0.4.0/Common'
Building object file octaviz.o...
/octaviz-0.4.0/Common/octaviz.cc: In constructor 'vtk_object::vtk_object(vtkObjectBase*, bool)':
/octaviz-0.4.0/Common/octaviz.cc:117: error: cast from 'vtkObjectBase*' to 'unsigned int' loses precision
/octaviz-0.4.0/Common/octaviz.cc: In copy constructor 'vtk_object::vtk_object(const vtk_object&)':
/octaviz-0.4.0/Common/octaviz.cc:152: error: cast from 'vtkObjectBase*' to 'unsigned int' loses precision
/octaviz-0.4.0/Common/octaviz.cc: In destructor 'virtual vtk_object::~vtk_object()':
/octaviz-0.4.0/Common/octaviz.cc:165: error: cast from 'vtkObjectBase*' to 'unsigned int' loses precision
/octaviz-0.4.0/Common/octaviz.cc: In member function 'virtual unsigned int vtk_object::uint_value(bool, bool) const':
/octaviz-0.4.0/Common/octaviz.cc:183: error: cast from 'vtkObjectBase*' to 'unsigned int' loses precision
make[4]: *** [octaviz.o] Error 1
make[4]: Leaving directory `/octaviz-0.4.0/Common'

With the attached patch 'octaviz' can be compiled
on amd64 using gcc-4.0.

Regards
Andreas Jochens

diff -urN ../tmp-orig/octaviz-0.4.0/Common/octaviz.cc ./Common/octaviz.cc
--- ../tmp-orig/octaviz-0.4.0/Common/octaviz.cc	2004-10-24 04:09:13.000000000 +0200
+++ ./Common/octaviz.cc	2005-04-02 07:47:15.000000000 +0200
@@ -114,7 +114,7 @@
 	//std::cout << "Creating.\n" << std::flush;
 	std::map<unsigned int, int>& reference_count = get_reference_map();
 
-	unsigned int key = reinterpret_cast<unsigned int>( pointer );
+	unsigned long key = reinterpret_cast<unsigned long>( pointer );
 	
 	if ( belongs_to_octave ) 
 	{
@@ -149,7 +149,7 @@
 	//std::cout << "Creating copy.\n" << std::flush;
 	std::map<unsigned int, int>& reference_count = get_reference_map();
 
-	unsigned int key = reinterpret_cast<unsigned int>( vtk_pointer );
+	unsigned long key = reinterpret_cast<unsigned long>( vtk_pointer );
 	
 	// If this is a clone than it exists in reference count map
 	if ( reference_count.find(key) == reference_count.end() ) return;
@@ -162,7 +162,7 @@
 { 
 	//std::cout << "Destroying.\n" << std::flush;
 	std::map<unsigned int, int>& reference_count = get_reference_map();
-	unsigned int key = reinterpret_cast<unsigned int>( vtk_pointer );
+	unsigned long key = reinterpret_cast<unsigned long>( vtk_pointer );
 	// Check if the pointer is reference counted.
 	if ( reference_count.find(key) == reference_count.end() ) return;
 	
@@ -180,7 +180,7 @@
 
 unsigned int vtk_object::uint_value (bool req_int, bool frc_str_conv ) const
 {
-	return reinterpret_cast<unsigned int>(vtk_pointer);
+	return reinterpret_cast<unsigned long>(vtk_pointer);
 }
  
 bool vtk_object::is_defined (void) const 
diff -urN ../tmp-orig/octaviz-0.4.0/Common/vtkInitializeInteractor.cc ./Common/vtkInitializeInteractor.cc
--- ../tmp-orig/octaviz-0.4.0/Common/vtkInitializeInteractor.cc	2004-10-24 04:09:13.000000000 +0200
+++ ./Common/vtkInitializeInteractor.cc	2005-04-02 12:25:48.256947614 +0200
@@ -76,7 +76,7 @@
 	vtkXOpenGLRenderWindow* RenderWindow = reinterpret_cast<vtkXOpenGLRenderWindow*>(CurrentInteractor->GetRenderWindow());
 	Widget widg = CurrentInteractor->GetWidget();
 	Atom wm_delete_window = XInternAtom(XtDisplay(widg), "WM_DELETE_WINDOW", False);
-	vtk_delete_window_atoms[wm_delete_window] = reinterpret_cast<unsigned int>(RenderWindow);
+	vtk_delete_window_atoms[wm_delete_window] = reinterpret_cast<unsigned long>(RenderWindow);
     // turn off default delete response
 	XSetWMProtocols(XtDisplay(widg), XtWindow(widg), &wm_delete_window, 1);
   return retval;