[Bug c++/98436] New: issue with casting member function on linux32 bit only

2020-12-24 Thread samuel_benjamin at mentor dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98436

Bug ID: 98436
   Summary: issue with casting member function on linux32 bit only
   Product: gcc
   Version: 7.4.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: samuel_benjamin at mentor dot com
  Target Milestone: ---

Created attachment 49840
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49840&action=edit
TestCase

There is an issue with gcc 7.4.0 linux32 bit only, I tried the example below
with 4.7.4 , 5.3.0. 6.3.0 , all are working fine for both 32bit and 64 bit
except gcc-7.4.0 linux32.

The issue is i have an un-implemented member function in a class , and the
implementation is inside another stub file.

The main exe loads two shared librares ( systemc.so ) and (systemc_stubs.so) ,
the issue arrives when i casts the undefined member function pointer is :

on gcc-7.4.0- 32 bit :

(gdb) p tmp
$1 = &virtual table offset -134397620


on gcc-7.4.0 - 64 bit and many other gcc versions : 
$1 = (void (functor::*)(functor * const)) 0x77e4c15a
 <_ZN7MyClass17myUndefinedMethodEv()>


Files are below :
Class.h --> basic class
testbench.cpp --> this is the main file for the fist so ( systemc.so)
stub.cpp --> systemc_stubs.so
main.cpp --> main exe which loads the 2 so and executes the entry point.

Compilation :
g++ -shared -o systemc.so -Wl,-E -Wl,-Bsymbolic -lm testbench.cpp -g
g++ -shared -o systemc_stubs.so -Wl,-E -Wl,-Bsymbolic -lm stub.cpp -g
g++ main.cpp -g -ldl -o testmain

[Bug c++/98436] issue with casting member function on linux32 bit only

2020-12-24 Thread samuel_benjamin at mentor dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98436

Samuel Benjamin  changed:

   What|Removed |Added

 Status|RESOLVED|UNCONFIRMED
 Resolution|INVALID |---

--- Comment #2 from Samuel Benjamin  ---
Hi,
_ZN7MyClass17myUndefinedMethodEv is the decorated name i got out from nm.
It is working with all the gcc versions except 7.4.0 32 bit, what do you
suggest here ?

The stub.cpp is automatically generated file to handle undefined refs.

[Bug c++/98436] issue with casting member function on linux32 bit only

2020-12-24 Thread samuel_benjamin at mentor dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98436

--- Comment #4 from Samuel Benjamin  ---
I got your point, But why is this working with 64bit and other gcc versions
other than 7.4.0 - 32 bit ?

[Bug c++/98436] issue with casting member function on linux32 bit only

2020-12-24 Thread samuel_benjamin at mentor dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98436

Samuel Benjamin  changed:

   What|Removed |Added

 Status|RESOLVED|UNCONFIRMED
 Resolution|INVALID |---

--- Comment #5 from Samuel Benjamin  ---
C++ Standard 5.4 "Explicit type conversion",
clause 7: a pointer to member of derived class type may be explicitly converted
to a pointer to member of an unambiguous non-virtual base class type.