Build the following project :
sobj.h :
#include <iostream>
#define Q_DECL_EXPORT __attribute__((visibility("default")))
class Q_DECL_EXPORT Object
{
public:
template <typename Func1>
static inline void connect(const Object *sender, Func1 signal)
{
std::cout << "From template : " << (void *)signal << "\n";
connectImpl(sender, reinterpret_cast<void **>(&signal));
}
private:
static void connectImpl(const Object *sender, void **signal);
};
class Q_DECL_EXPORT MyObject : public Object {
public:
MyObject();
public:
int signalFunction(int hello);
};
sobj.cpp :
#include "sobj.h"
void Object::connectImpl(const Object *sender, void **signal)
{
std::cout << "From sobj : " << (void *)&MyObject::signalFunction << "\n";
}
MyObject::MyObject()
{
connect(this, &MyObject::signalFunction);
}
int MyObject::signalFunction(int hello)
{
hello++;
}
main.cpp :
#include "sobj.h"
int main()
{
std::cout << "From main : " << (void *)&MyObject::signalFunction << "\n";
MyObject o;
return 0;
}
Makefile :
CXX = ppc-amigaos-g++
APP_CXXFLAGS = -athread=native
LINK = ppc-amigaos-g++
APP_LFLAGS = -use-dynld -Wl,--export-dynamic -Wl,--no-undefined -athread=native
APP_OBJECTS = main.o
SOBJ_OBJECTS = sobj.o
app: $(APP_OBJECTS) sobjs/sobj.so
$(LINK) $(APP_LFLAGS) -o app $(APP_OBJECTS) sobjs/sobj.so
sobjs/sobj.so: $(SOBJ_OBJECTS)
$(LINK) -shared -fPIC -o sobjs/sobj.so $(SOBJ_OBJECTS)
sobj.o: sobj.cpp
$(CXX) -c -fPIC -o sobj.o sobj.cpp
main.o: main.cpp
$(CXX) -c -o main.o main.cpp
clean :
rm *.o
rm sobjs/sobj.so
rm app
The resulting app will write different values for &MyObject::signalFunction, when run. They should of course be the same, which is why this is indeed a bug.
Reactions are currently unavailable
Build the following project :
sobj.h :
#include <iostream> #define Q_DECL_EXPORT __attribute__((visibility("default"))) class Q_DECL_EXPORT Object { public: template <typename Func1> static inline void connect(const Object *sender, Func1 signal) { std::cout << "From template : " << (void *)signal << "\n"; connectImpl(sender, reinterpret_cast<void **>(&signal)); } private: static void connectImpl(const Object *sender, void **signal); }; class Q_DECL_EXPORT MyObject : public Object { public: MyObject(); public: int signalFunction(int hello); };sobj.cpp :
#include "sobj.h" void Object::connectImpl(const Object *sender, void **signal) { std::cout << "From sobj : " << (void *)&MyObject::signalFunction << "\n"; } MyObject::MyObject() { connect(this, &MyObject::signalFunction); } int MyObject::signalFunction(int hello) { hello++; }main.cpp :
#include "sobj.h" int main() { std::cout << "From main : " << (void *)&MyObject::signalFunction << "\n"; MyObject o; return 0; }Makefile :
CXX = ppc-amigaos-g++ APP_CXXFLAGS = -athread=native LINK = ppc-amigaos-g++ APP_LFLAGS = -use-dynld -Wl,--export-dynamic -Wl,--no-undefined -athread=native APP_OBJECTS = main.o SOBJ_OBJECTS = sobj.o app: $(APP_OBJECTS) sobjs/sobj.so $(LINK) $(APP_LFLAGS) -o app $(APP_OBJECTS) sobjs/sobj.so sobjs/sobj.so: $(SOBJ_OBJECTS) $(LINK) -shared -fPIC -o sobjs/sobj.so $(SOBJ_OBJECTS) sobj.o: sobj.cpp $(CXX) -c -fPIC -o sobj.o sobj.cpp main.o: main.cpp $(CXX) -c -o main.o main.cpp clean : rm *.o rm sobjs/sobj.so rm appThe resulting app will write different values for &MyObject::signalFunction, when run. They should of course be the same, which is why this is indeed a bug.