Re: sizeof((..))

2011-01-31 Thread Andreas Schwab
Ralf Corsepius writes: > However, the rationale why autoconf is doing so, so far escapes me. Read the comments. Andreas. -- Andreas Schwab, sch...@redhat.com GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E "And now for something completely different."

Re: sizeof((..))

2011-01-31 Thread Jonathan Wakely
On 31 January 2011 12:16, Hagen Paul Pfeifer wrote: > > On Mon, 31 Jan 2011 09:19:07 +, Jonathan Wakely wrote: > >> The code is wrong. sizeof expects either an expression, or a >> parenthesized type-id.  (long) is not a type-id so ((long)) is not a >> parenthesized type-id, therefore it must be

Re: sizeof((..))

2011-01-31 Thread Ralf Corsepius
On 01/31/2011 01:02 PM, Andreas Schwab wrote: Ralf Corsepius writes: ATM, I am not sure, if what autoconf does actually is useful, but this is a different matter. autoconf needs to deliberately trigger errors in a lot of its tests in order to do the right thing. I know, but ... ... the auto

Re: sizeof((..))

2011-01-31 Thread Hagen Paul Pfeifer
On Mon, 31 Jan 2011 09:19:07 +, Jonathan Wakely wrote: > The code is wrong. sizeof expects either an expression, or a > parenthesized type-id. (long) is not a type-id so ((long)) is not a > parenthesized type-id, therefore it must be interpreted as an > expression, but it's not a valid

Re: sizeof((..))

2011-01-31 Thread Andreas Schwab
Ralf Corsepius writes: > ATM, I am not sure, if what autoconf does actually is useful, but this > is a different matter. autoconf needs to deliberately trigger errors in a lot of its tests in order to do the right thing. Andreas. -- Andreas Schwab, sch...@redhat.com GPG Key fingerprint = D4E8

Re: sizeof((..))

2011-01-31 Thread Ralf Corsepius
On 01/31/2011 10:19 AM, Jonathan Wakely wrote: On 31 January 2011 08:59, Ralf Corsepius wrote: Hi, gcc emits an error, when compiling this code-snippet: --- snip --- extern int x; void foo (void) { x = sizeof ((long)); } --- snip --- # gcc -Wall -o tmp.o -c tmp.c tmp.c: In function ‘foo’:

Re: sizeof((..))

2011-01-31 Thread Jonathan Wakely
On 31 January 2011 08:59, Ralf Corsepius wrote: > Hi, > > gcc emits an error, when compiling this code-snippet: > > --- snip --- > extern int x; > > void > foo (void) > { >  x = sizeof ((long)); > } > --- snip --- > > # gcc -Wall -o tmp.o -c tmp.c > tmp.c: In function ‘foo’: > tmp.c:6:21: error: e

Re: sizeof in initializer expression not working as expected

2009-01-29 Thread Paolo Bonzini
Bruce Korb wrote: > Hi, > > I was trying to figure out how come a memory allocation was short. > I think I've stumbled onto the issue. "evt_t" is a 48 byte structure > and "tpd_uptr" is a uintptr_t. "sz" initializes to 52 (decimal). > The value would be correct if I were not trying to multiply t

Re: sizeof(array) with variable-length array parameter

2008-04-09 Thread peter . kourzanov
On Wed, Apr 09, 2008 at 01:22:15PM +0100, Andrew Haley wrote: > [EMAIL PROTECTED] wrote: > > Dear gcc users and developers, > > > > This might be a stupid question, nevertheless... > > > > I've been wondering for a long time, why the behaviour of > > variable-length arrays w.r.t. the sizeof

Re: sizeof(array) with variable-length array parameter

2008-04-09 Thread Andrew Haley
[EMAIL PROTECTED] wrote: > Dear gcc users and developers, > > This might be a stupid question, nevertheless... > > I've been wondering for a long time, why the behaviour of > variable-length arrays w.r.t. the sizeof operator is different > for local/auto variables and for function arguments

Re: sizeof struct { short x } on arm gcc-3.2.1

2007-02-16 Thread Mike Stump
On Feb 16, 2007, at 8:57 AM, Rutger Hofman wrote: If I declare the struct 'packed', then it is size 2. That is enough for my purposes. I hope that won't greatly change through versions... Also, there is: @item [EMAIL PROTECTED] @opindex mstructure-size-boundary The size of all structures and

Re: sizeof struct { short x } on arm gcc-3.2.1

2007-02-16 Thread Rutger Hofman
Paul Brook wrote: My (embedded) development system is gcc-3.2.1 arm-elf. I don't really understand its value for sizeof(struct { short x }). sizeof s_sh 4 sizeof short 2 This is a feature of the ARM ABI you are using. All structures are word aligned (which implies being word sized). Paul

Re: sizeof struct { short x } on arm gcc-3.2.1

2007-02-16 Thread Paul Brook
> My (embedded) development system is gcc-3.2.1 arm-elf. I don't really > understand its value for sizeof(struct { short x }). > sizeof s_sh 4 > sizeof short 2 This is a feature of the ARM ABI you are using. All structures are word aligned (which implies being word sized). Paul

Re: sizeof() function parameter array: known problem?

2005-07-01 Thread Jonathan Wakely
On Fri, Jul 01, 2005 at 10:45:19AM +0200, Etienne Lorrain wrote: > The result of this funtion is 1, is there a C lawyer around? The parameter is treated as unsigned* since an array is converted to a pointer when passed through a function. C99 says in 6.7.5.3: [#7] A declaration of a parame

Re: sizeof() function parameter array: known problem?

2005-07-01 Thread Andrew Haley
Etienne Lorrain writes: > The result of this funtion is 1, is there a C lawyer around? > > $ cat tmp.c > unsigned fct (unsigned array[10]) > { > return sizeof(array) / sizeof(array[0]); > } This is 6.7.5.3, Para. 7. Andrew.

Re: sizeof(int) in testsuite

2005-06-04 Thread Björn Haase
Am Freitag, 3. Juni 2005 10:48 schrieb Mark Mitchell: > DJ Delorie wrote: > > Do we have a standard way of telling the testsuite how big target > > types are, or some standard "this test assumes 32 bit int" dejagnu > > flag? > > I don't think we have any way of doing this at present. I could be >

Re: sizeof(int) in testsuite

2005-06-03 Thread DJ Delorie
> struct-layout-1_generate.c is run on the host, not on the target. > And for hosts AFAIK GCC requires 32-bit int. But the structures it generates assume 32-bit ints: T(0,enum E2 a:31;,B(0,a,e2_m1,e2_0)) You can't have a 31 bit enum on a 16 bit target. You get messages like this:

Re: sizeof(int) in testsuite

2005-06-03 Thread Joe Buck
On Fri, Jun 03, 2005 at 11:14:15AM +0200, Jakub Jelinek wrote: > On Fri, Jun 03, 2005 at 02:07:57AM -0700, Mark Mitchell wrote: > > >Doesn't "is-effective-target ilp32" test for 32 bits int? > > > > Good point! I forgot about that. My brain is stuck in some other year. > > > > That doesn't let

Re: sizeof(int) in testsuite

2005-06-03 Thread Jakub Jelinek
On Thu, Jun 02, 2005 at 09:49:03PM -0400, DJ Delorie wrote: > > gcc.dg/compat/struct-layout-1_generate.c assumes sizeof(int) is 4. > This of course fails on any target where sizeof(int) is 2. They may > fail when sizeof(int) is 8 too, or at least they won't be testing the > full range of possibil

Re: sizeof(int) in testsuite

2005-06-03 Thread Jakub Jelinek
On Fri, Jun 03, 2005 at 02:07:57AM -0700, Mark Mitchell wrote: > >Doesn't "is-effective-target ilp32" test for 32 bits int? > > Good point! I forgot about that. My brain is stuck in some other year. > > That doesn't let you adjust the test based on the compiler, but it does > let you skip test

Re: sizeof(int) in testsuite

2005-06-03 Thread Mark Mitchell
Steven Bosscher wrote: On Friday 03 June 2005 10:48, Mark Mitchell wrote: DJ Delorie wrote: Do we have a standard way of telling the testsuite how big target types are, or some standard "this test assumes 32 bit int" dejagnu flag? I don't think we have any way of doing this at present. I c

Re: sizeof(int) in testsuite

2005-06-03 Thread Steven Bosscher
On Friday 03 June 2005 10:48, Mark Mitchell wrote: > DJ Delorie wrote: > > Do we have a standard way of telling the testsuite how big target > > types are, or some standard "this test assumes 32 bit int" dejagnu > > flag? > > I don't think we have any way of doing this at present. I could be > wro

Re: sizeof(int) in testsuite

2005-06-03 Thread Mark Mitchell
DJ Delorie wrote: Do we have a standard way of telling the testsuite how big target types are, or some standard "this test assumes 32 bit int" dejagnu flag? I don't think we have any way of doing this at present. I could be wrong, though. We could certainly add logic to compute this, using