Re: [PATCH 1/9] Define a structure for object IDs.

2014-05-05 Thread David Kastrup
Andreas Schwab sch...@linux-m68k.org writes: Johannes Sixt j...@kdbg.org writes: Isn't internal padding only allowed between members to achieve correct alignment of later members, and at the end only sufficient padding so that members are aligned correctly when the struct is part of an

Re: [PATCH 1/9] Define a structure for object IDs.

2014-05-05 Thread Andreas Schwab
David Kastrup d...@gnu.org writes: It does not as far as I can see guarantee that a pointer to something of the same type of its first member can be converted to a pointer to a struct even if the struct only contains a member of such type. This sentence doesn't make any sense. If you have an

Re: [PATCH 1/9] Define a structure for object IDs.

2014-05-05 Thread James Denholm
On 5 May 2014 19:23:06 GMT+10:00, Andreas Schwab sch...@linux-m68k.org wrote: David Kastrup d...@gnu.org writes: It does not as far as I can see guarantee that a pointer to something of the same type of its first member can be converted to a pointer to a struct even if the struct only contains

Re: [PATCH 1/9] Define a structure for object IDs.

2014-05-05 Thread David Kastrup
Andreas Schwab sch...@linux-m68k.org writes: David Kastrup d...@gnu.org writes: It does not as far as I can see guarantee that a pointer to something of the same type of its first member can be converted to a pointer to a struct even if the struct only contains a member of such type. This

Re: [PATCH 1/9] Define a structure for object IDs.

2014-05-05 Thread Michael Haggerty
On 05/05/2014 11:50 AM, David Kastrup wrote: The case we are talking about is basically passing a pointer to some actual bonafide toplevel unsigned char [20] object to a routine that expects a pointer to a struct _only_ containing one such unsigned char [20] element. This is the situation

Re: [PATCH 1/9] Define a structure for object IDs.

2014-05-05 Thread Andreas Schwab
David Kastrup d...@gnu.org writes: Your premise is _not_ assumed in my statement. My premise was a pointer to something of the same type of [the struct's] first member. That does quite explicitly _not_ state that an object of struct type is in existence. So you are not taking about struct

Re: [PATCH 1/9] Define a structure for object IDs.

2014-05-05 Thread David Kastrup
Andreas Schwab sch...@linux-m68k.org writes: David Kastrup d...@gnu.org writes: Your premise is _not_ assumed in my statement. My premise was a pointer to something of the same type of [the struct's] first member. That does quite explicitly _not_ state that an object of struct type is in

Re: [PATCH 1/9] Define a structure for object IDs.

2014-05-05 Thread Felipe Contreras
Andreas Schwab wrote: This thread is about objects of type struct object_id, and their address is always the same as the address of its first member. Nothing else is relevant. Indeed. I suggest you ingore that guy, he will only derail the discussion. -- Felipe Contreras -- To unsubscribe

Re: [PATCH 1/9] Define a structure for object IDs.

2014-05-04 Thread Michael Haggerty
On 05/03/2014 10:12 PM, brian m. carlson wrote: Many places throughout the code use unsigned char [20] to store object IDs (SHA-1 values). This leads to lots of hardcoded numbers throughout the codebase. It also leads to confusion about the purposes of a buffer. Introduce a structure for

Re: [PATCH 1/9] Define a structure for object IDs.

2014-05-04 Thread Johannes Sixt
Am 04.05.2014 08:07, schrieb Michael Haggerty: On 05/03/2014 10:12 PM, brian m. carlson wrote: Introduce a structure for object IDs. This allows us to obtain the benefits of compile-time checking for misuse. The structure is expected to remain the same size and have the same alignment

Re: [PATCH 1/9] Define a structure for object IDs.

2014-05-04 Thread David Kastrup
Johannes Sixt j...@kdbg.org writes: Am 04.05.2014 08:07, schrieb Michael Haggerty: On 05/03/2014 10:12 PM, brian m. carlson wrote: Introduce a structure for object IDs. This allows us to obtain the benefits of compile-time checking for misuse. The structure is expected to remain the same

Re: [PATCH 1/9] Define a structure for object IDs.

2014-05-04 Thread Andreas Schwab
Johannes Sixt j...@kdbg.org writes: I think that a compiler that has different size and alignment requirements for the proposed struct object_id and an unsigned char[20] would, strictly speaking, not be a C compiler. Unlike arrays, a struct can have arbitrary internal padding. It is

Re: [PATCH 1/9] Define a structure for object IDs.

2014-05-04 Thread Duy Nguyen
On Sun, May 4, 2014 at 1:07 PM, Michael Haggerty mhag...@alum.mit.edu wrote: On 05/03/2014 10:12 PM, brian m. carlson wrote: Many places throughout the code use unsigned char [20] to store object IDs (SHA-1 values). This leads to lots of hardcoded numbers throughout the codebase. It also

Re: [PATCH 1/9] Define a structure for object IDs.

2014-05-04 Thread brian m. carlson
On Sun, May 04, 2014 at 08:07:26AM +0200, Michael Haggerty wrote: Please clarify whether you plan to rely on all platforms having the same size and alignment constraints for correctness, or whether that observation of the status quo is only meant to reassure us that this change won't cause

Re: [PATCH 1/9] Define a structure for object IDs.

2014-05-04 Thread Andreas Schwab
brian m. carlson sand...@crustytoothpaste.net writes: I don't even plan to write the code assuming that offsetof(struct object_id, oid) is 0. This is guaranteed by the C standard, though. Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3

Re: [PATCH 1/9] Define a structure for object IDs.

2014-05-04 Thread David Kastrup
Andreas Schwab sch...@linux-m68k.org writes: brian m. carlson sand...@crustytoothpaste.net writes: I don't even plan to write the code assuming that offsetof(struct object_id, oid) is 0. This is guaranteed by the C standard, though. Any reference? -- David Kastrup -- To unsubscribe from

Re: [PATCH 1/9] Define a structure for object IDs.

2014-05-04 Thread Andreas Schwab
David Kastrup d...@gnu.org writes: Andreas Schwab sch...@linux-m68k.org writes: brian m. carlson sand...@crustytoothpaste.net writes: I don't even plan to write the code assuming that offsetof(struct object_id, oid) is 0. This is guaranteed by the C standard, though. Any reference?

Re: [PATCH 1/9] Define a structure for object IDs.

2014-05-04 Thread David Kastrup
Andreas Schwab sch...@linux-m68k.org writes: David Kastrup d...@gnu.org writes: Andreas Schwab sch...@linux-m68k.org writes: brian m. carlson sand...@crustytoothpaste.net writes: I don't even plan to write the code assuming that offsetof(struct object_id, oid) is 0. This is guaranteed

Re: [PATCH 1/9] Define a structure for object IDs.

2014-05-04 Thread Andreas Schwab
David Kastrup d...@gnu.org writes: Andreas Schwab sch...@linux-m68k.org writes: David Kastrup d...@gnu.org writes: Andreas Schwab sch...@linux-m68k.org writes: brian m. carlson sand...@crustytoothpaste.net writes: I don't even plan to write the code assuming that offsetof(struct

Re: [PATCH 1/9] Define a structure for object IDs.

2014-05-04 Thread Johannes Sixt
Am 04.05.2014 12:55, schrieb Andreas Schwab: Johannes Sixt j...@kdbg.org writes: I think that a compiler that has different size and alignment requirements for the proposed struct object_id and an unsigned char[20] would, strictly speaking, not be a C compiler. Unlike arrays, a struct can

Re: [PATCH 1/9] Define a structure for object IDs.

2014-05-04 Thread Andreas Schwab
Johannes Sixt j...@kdbg.org writes: Isn't internal padding only allowed between members to achieve correct alignment of later members, and at the end only sufficient padding so that members are aligned correctly when the struct is part of an array? The standard allows arbitrary internal

[PATCH 1/9] Define a structure for object IDs.

2014-05-03 Thread brian m. carlson
Many places throughout the code use unsigned char [20] to store object IDs (SHA-1 values). This leads to lots of hardcoded numbers throughout the codebase. It also leads to confusion about the purposes of a buffer. Introduce a structure for object IDs. This allows us to obtain the benefits of