(bringing this back to the original thread rather than the digest)

On 20 Jun 2023, at 14:54, Turtle Creek Software <supp...@turtlesoft.com> wrote:
On 19 Jun 2023, at 17:30, Thiago Macieira <thiago.macie...@intel.com> wrote:

On Monday, 19 June 2023 04:13:51 PDT Turtle Creek Software wrote:
The debugger showed the correct address but failed to cast a
parameter.

Can the ARM compiler handle #pragma pack (2) ?

What does this have to do with casting? It would really help if you gave exact
error messages. That includes warnings about ignored / unrecognised pragmas.

Anyway, why do you want #pragma produce_slow_memory_accesses?



Our code has structs that were set up in 16-bit processor days, and it uses an 
object database library that probably started for 8-bit.  Most structs were 
easy to revise for 4 and 8 byte alignments, but some parse data from disk. 
Those are the ones that get #pragma pack (2).  Any speed hit is tiny compared 
to disk access time.

We still need those old structs for a one-time file conversion of user data 
that may date back to the 90s. The code reads old structs, then writes newer 
ones with modern alignment. Sometimes arrays of them.

It worked fine in Qt5.  In Qt6 for ARM, 2-byte aligned structs mostly work, but 
if they go through a void pointer they don't cast back properly.  No specific 
system error, just our code sanity-checking and reporting the nullptr.

There's only a few places where we use function pointers with void parameters.  
They are hard to debug so it's fine to rewrite the last of them.

But that database library also loses structs when coming back from (the) void. 
It also worked in Qt5, but breaks for Qt6 on ARM. Their code is a nightmare, 
and we only need it once to read old files.  A rewrite would take years.

Does that make sense?

We haven't built with Qt6 for Windows yet but will do that soon. It may help 
narrow down where the problem lies.


I’m trying to understand what the differences are between “works” and “doesn’t 
work”. You have both Qt 5 vs Qt 6, and you have Intel vs ARM macs. So far you 
are saying that it works with Qt 5 on Intel, and that it doesn’t work with Qt 6 
on ARM. Do things work with Qt 6 on Intel macs? Do things work with Qt 5 on 
ARM? Are you building with the same toolchain versions, or are the clang 
versions different?

You’re also saying that this is all plain C/C++ code.

I’m not quite seeing yet what role Qt is playing in this - and maybe it doesn’t 
have any, in which case it’s still fine to consult this mailing list of course, 
but it would help to get this clarified :)

Either way, it would perhaps help to boil all this down to some minimal code; 
you have a 2-byte aligned struct that you cast to and from void *, this should 
be reproducible with small bit of code. And if you have that, then comparing 
the assembly you get out of your compiler when targeting Intel vs ARM might 
give some hints.


Volker

_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to