1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 3.2//EN">
4 <TITLE> [IRCServices Coding] GCC3
6 <LINK REL=
"Index" HREF=
"index.html" >
7 <LINK REL=
"made" HREF=
"mailto:ircservices-coding%40ircservices.za.net?Subject=%5BIRCServices%20Coding%5D%20GCC3&In-Reply-To=004601c1be40%2413b778a0%240200000a%40stormkeepers.com">
8 <META NAME=
"robots" CONTENT=
"index,nofollow">
9 <META http-equiv=
"Content-Type" content=
"text/html; charset=us-ascii">
10 <LINK REL=
"Previous" HREF=
"000327.html">
11 <LINK REL=
"Next" HREF=
"000342.html">
13 <BODY BGCOLOR=
"#ffffff">
14 <H1>[IRCServices Coding] GCC3
</H1>
16 <A HREF=
"mailto:ircservices-coding%40ircservices.za.net?Subject=%5BIRCServices%20Coding%5D%20GCC3&In-Reply-To=004601c1be40%2413b778a0%240200000a%40stormkeepers.com"
17 TITLE=
"[IRCServices Coding] GCC3">quension at softhome.net
19 <I>Mon Feb
25 18:
28:
57 PST
2002</I>
21 <LI>Previous message:
<A HREF=
"000327.html">[IRCServices Coding] GCC3
23 <LI>Next message:
<A HREF=
"000342.html">[IRCServices Coding] GCC3 sizes
25 <LI> <B>Messages sorted by:
</B>
26 <a href=
"date.html#328">[ date ]
</a>
27 <a href=
"thread.html#328">[ thread ]
</a>
28 <a href=
"subject.html#328">[ subject ]
</a>
29 <a href=
"author.html#328">[ author ]
</a>
34 <PRE>On Monday, February
25,
2002, at
01:
04 PM, Kelmar K. Firesun wrote:
36 ><i> ----- Original Message -----
37 </I>><i> From:
"Andrew Church
" <<A HREF=
"http://www.ircservices.za.net/mailman/listinfo/ircservices-coding">achurch at achurch.org
</A>>
39 </I>>>>><i> The major problem I have with GCC
3.0 is that it reorders
40 </I>>>>><i> structures
41 </I>>>>><i> (or at least did at one point), which would break convert-db, and in
42 </I>>>>><i> general is a Bad Idea (among other things it prevents you from laying
43 </I>>>>><i> structures on top of data in memory). Does anyone know if this has
44 </I>>>>><i> been
45 </I>>>>><i> fixed or if there's a way around it?
47 </I>>>><i> Are you sure it reordered them? It might just have changed the padding
48 </I>>>><i> between members, which compilers have been known to do in the past.
49 </I>>>><i> Anyhow, I haven't tried convert-db yet but I will when I get the
50 </I>>>><i> chance
52 </I>>><i> To be perfectly honest, that's based on hearsay--I haven't
53 </I>>><i> confirmed
54 </I>>><i> it one way or the other. But I do recall quite a lot of discussion on
56 </I>>><i> point, so I'd like to have confirmation that it does work before
57 </I>>><i> "officially
" endorsing it.
59 Reordering is not permitted by the ANSI/ISO C standards.
61 ><i> I could certanly see it padding the data structures.
62 </I>><i> This would be to optimize memory access by keeping things
63 </I>><i> aligned with the CPU's WORD size.
64bits in the case of
64 </I>><i> most Intel Pentiums if I recall correctly.
66 Usually
32 bits, possible exceptions where optimized structures
67 occur (MMX usage, for example).
69 ><i> For example, if you have a structure like so:
71 </I>><i> struct foo
73 </I>><i> int_16 bar;
74 </I>><i> int_8 baz;
77 </I>><i> The compiler would append or prepend (depending on compiler)
78 </I>><i> on an extra
40bits of data to align it in memory on each
79 </I>><i> allocation.
81 Under
32bit x86, it's likely to add
8 bits of padding to the end
82 of the structure. The alignment is for the width of the largest
85 ><i> This is a very common optimization for speed in many compilers.
86 </I>><i> I'm actually very surprised that GCC would just now be
87 </I>><i> implementing it.
89 Not just for speed; some platforms require aligned types
90 (such as Motorola
68k and PPC under certain conditions).
91 It's also well-documented by the C standards.
93 Partly for this reason, mapping structs onto arbitrary data in
94 memory results in undefined behavior.
105 <LI>Previous message:
<A HREF=
"000327.html">[IRCServices Coding] GCC3
107 <LI>Next message:
<A HREF=
"000342.html">[IRCServices Coding] GCC3 sizes
109 <LI> <B>Messages sorted by:
</B>
110 <a href=
"date.html#328">[ date ]
</a>
111 <a href=
"thread.html#328">[ thread ]
</a>
112 <a href=
"subject.html#328">[ subject ]
</a>
113 <a href=
"author.html#328">[ author ]
</a>