g++ struct mapping change

Asked by David R. Doucette

I just installed Version 10.4 lucid lynx, and ALL of my programs no longer work. After chasing this for 3 days, we found out that g++ now maps structures differently than Jaunty or Karmic. Try this test: Make a struct with a char, a double, another char, and antoher double, in that order. WIth Januty and Karmic, the structures are only 24 bytes. With Lucid, they are 32, and the offsets of the doubles moved. It looks like Lucid now maps the doubles onto offsets divisible by 8 rather than by 4 like it used to. The result is total chaos, and no way to read our data.

We have stopped deployment of Lucid cold until we find a way out of this. Any struct that has doubles in it mixed with other data types will have this problem. One workaround we can't try (we have a lot of legacy data) is to put the doubles first, then floats and ints, then chars, but this can only be done with new code, assuming it makes sense to do this.

The operating system is Ubuntu 64 bit in all cases on PCs.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu gcc-defaults Edit question
Assignee:
No assignee Edit question
Solved by:
David R. Doucette
Solved:
Last query:
Last reply:
Revision history for this message
David R. Doucette (ddoucette) said :
#1

I have an update on this from a combination of Google and GNU that solves the problem.

First, use Synaptic to install the following packages:

libc6-dev-i386
multilib

Then compile using g++ -m32

Yes, this will generate 32 bit code, but it sure beats being dead.

Next, I plan to remap the structures in order of attribute: doubles, floats, ints, chars. That should map the structures the same for both 32 and 64 bits, and we can go back to life as it was. Then all we need to do is recompile a few tens of thousands of lines of code.