[Bug report] 64bit issues in ...

In previous post Roman Lygin make some patch under AdvApp2Var_MathBase. It's tested and working for 100%%.
In my case I have easy convert like:
int x = *((int*)(&arg)); and It's working under GCC 4 or higher

Also files needs to be patched:
in inc folder, without Roman's patched files:

OSD_DirectoryIterator.hxx
OSD_EnvironmentIterator.hxx
OSD_EnvironmentIterator.hxx
OSD_FileIterator.hxx
OSD_FileNode.hxx
OSD_SharedMemory.hxx
OSD_ThreadFunction.hxx
TDF_LabelMapHasher.lxx

in sources, without Roman's patched files:
MFT_FontManager.cxx
NCollection_IncAllocator.cxx (on the forum has patched too)
OpenGl_polygon.cxx
OpenGl_polygonholes.cxx
OpenGl_subrvis.cxx
OpenGl_txgl.cxx
OSD_DirectoryIterator.cxx
OSD_EnvironmentIterator.cxx
OSD_File.cxx
OSD_FileIterator.cxx
OSD_FileNode.cxx
OSD_Process.cxx
OSD_SharedMemory.cxx
OSD_signal_WNT.cxx
OSD_Thread.cxx
OSD_WNT.cxx
OSD_WNT_1.cxx
Visual3d_View.cxx
Visual3d_ViewManager.cxx
WNT_DDriver.cxx
WNT_GraphicDevice.cxx
WNT_MFTDraw.cxx
WNT_TextManager.cxx
WNT_WDriver.cxx
WNT_Window.cxx

In all of this files we have dangerous conversion on 32 / 64 bit types. I don't use cast method because it's not safe too (I think so) if patch with *((int*)(&arg)) conversion is needed I can upload this here.

Roman Lygin's picture

Hi Yuriy,
Thanks for pointing out further issues.

You seem to refer to this thread - http://www.opencascade.org/org/forum/thread_22101/,so let me put a direct link to it for common convenience.

Could you please post your patch here for review ? I cannot easily see what needs changing in OSD_DirectoryIterator, for instance.

Indeed, there are many more warnings when building an app in 64 bit, so it's definitively worth for OCC team addressing them. The bad news is that current code hides potential issues with casts which are valid in 32bit mode but can become wrong in 64:

long l = (long)(&var);
...
MyVar* p = (var*)(l);

The code will compile with no warnings and hides an error.

Roman
P.S. I used to prefer C++-style casts (static_cast, reinterpret_cast, ...) to C-style ( (MyVar)) as they are more explicit and strict.

JuryS's picture

Hi, in I really know some cast method in asm code. It's a hack method. Really if we convert with *(int*)arg the compiler hide warning, but when we try the result the app is broken. I make tests for last week and my patches work fine like your patch. Give me some time for generate diff files.

JuryS's picture

I don't create the diff files because there is more differences with original sources. I'm write into txt all changes that I make to work OCC librarys on 64 bit Windows. Many thanks you if you create the patch for OCC sources originally.

Best regards,
Yuriy

Attachments: 
JuryS's picture

And don't forget replace WIN64 definitions with _WIN64.

JuryS's picture

Roman, what are you think about memsize types ? It's a really may take some effect on 64 bit Win/Linux platform ???