Re: [arch-general] gcc: loop do not terminate

2013-05-14 Thread Daniel Micay
On Tue, May 14, 2013 at 11:47 AM, LANGLOIS Olivier PIS -EXT wrote: >> void testing(void) >> { >> #define NR_STRUCT_A (4) >> struct B* ptr = malloc(sizeof(struct B) + NR_STRUCT_A*sizeof(struct >> A)); >> >> ptr->numelem = NR_STRUCT_A; >> ptr->item= (struct A*)(ptr+1); >> >>

Re: [arch-general] gcc: loop do not terminate

2013-05-14 Thread Daniel Micay
On Tue, May 14, 2013 at 9:41 AM, Olivier Langlois wrote: > On Tue, 2013-05-14 at 08:52 +0200, Martti Kühne wrote: >> Sorry if this is OT and a dumb question, but are you sure you want >> >> On Mon, May 13, 2013 at 8:20 PM, LANGLOIS Olivier PIS -EXT >> wrote: >> [...] >> > struct B >> > { >> >

Re: [arch-general] gcc: loop do not terminate

2013-05-14 Thread LANGLOIS Olivier PIS -EXT
> void testing(void) > { > #define NR_STRUCT_A (4) > struct B* ptr = malloc(sizeof(struct B) + NR_STRUCT_A*sizeof(struct > A)); > > ptr->numelem = NR_STRUCT_A; > ptr->item= (struct A*)(ptr+1); > > ptr->item[0].a = 0; > ptr->item[1].a = 1; > ptr->item[2].a

Re: [arch-general] gcc: loop do not terminate

2013-05-14 Thread Olivier Langlois
On Tue, 2013-05-14 at 08:52 +0200, Martti Kühne wrote: > Sorry if this is OT and a dumb question, but are you sure you want > > On Mon, May 13, 2013 at 8:20 PM, LANGLOIS Olivier PIS -EXT > wrote: > [...] > > struct B > > { > > int numelem; > > /* > > * Old C trick to defi

Re: [arch-general] gcc: loop do not terminate

2013-05-14 Thread Olivier Langlois
On Tue, 2013-05-14 at 04:50 -0400, Daniel Micay wrote: > On Tue, May 14, 2013 at 3:49 AM, wrote: > > If this function initArr() is moved to the same cpp file of main(), > > all optimization level get the same result. > Good observation. Having a separate TU for init function was intentional

Re: [arch-general] gcc: loop do not terminate

2013-05-14 Thread goodmenzy
On 2013-05-14 05:42:04, Daniel Micay wrote: > Date: Tue, 14 May 2013 05:42:04 -0400 > From: Daniel Micay > To: General Discussion about Arch Linux > Subject: Re: [arch-general] gcc: loop do not terminate > > On Tue, May 14, 2013 at 5:02 AM, wrote: > > On 2013-05-1

Re: [arch-general] gcc: loop do not terminate

2013-05-14 Thread Daniel Micay
On Tue, May 14, 2013 at 5:02 AM, wrote: > On 2013-05-14 04:50:11, Daniel Micay wrote: >> Date: Tue, 14 May 2013 04:50:11 -0400 >> From: Daniel Micay >> To: General Discussion about Arch Linux >> Subject: Re: [arch-general] gcc: loop do not terminate >> &

Re: [arch-general] gcc: loop do not terminate

2013-05-14 Thread goodmenzy
On 2013-05-14 04:50:11, Daniel Micay wrote: > Date: Tue, 14 May 2013 04:50:11 -0400 > From: Daniel Micay > To: General Discussion about Arch Linux > Subject: Re: [arch-general] gcc: loop do not terminate > > On Tue, May 14, 2013 at 3:49 AM, wrote: > > If this functi

Re: [arch-general] gcc: loop do not terminate

2013-05-14 Thread goodmenzy
On 2013-05-13 18:20:05, LANGLOIS Olivier PIS -EXT wrote: > Date: Mon, 13 May 2013 18:20:05 + > From: LANGLOIS Olivier PIS -EXT > To: "General Discussion about Arch Linux (arch-general@archlinux.org)" > > Subject: [arch-general] gcc: loop do not terminate >

Re: [arch-general] gcc: loop do not terminate

2013-05-14 Thread Daniel Micay
On Tue, May 14, 2013 at 3:49 AM, wrote: > If this function initArr() is moved to the same cpp file of main(), > all optimization level get the same result. That's the great thing about undefined behaviour, you never know what you'll get. It's really not something anyone should be relying on

Re: [arch-general] gcc: loop do not terminate

2013-05-14 Thread goodmenzy
On 2013-05-13 18:20:05, LANGLOIS Olivier PIS -EXT wrote: > Date: Mon, 13 May 2013 18:20:05 + > From: LANGLOIS Olivier PIS -EXT > To: "General Discussion about Arch Linux (arch-general@archlinux.org)" > > Subject: [arch-general] gcc: loop do not terminate >

Re: [arch-general] gcc: loop do not terminate

2013-05-13 Thread Thomas Bächler
Am 13.05.2013 22:59, schrieb LANGLOIS Olivier PIS -EXT: > I hear you. I, however, disagree when you qualify the old C trick pattern as > incorrect. It is incorrect according to C standards. There is no room for "disagreement". If you write non-conforming code, you cannot expect it to work right.

Re: [arch-general] gcc: loop do not terminate

2013-05-13 Thread Martti Kühne
Sorry if this is OT and a dumb question, but are you sure you want On Mon, May 13, 2013 at 8:20 PM, LANGLOIS Olivier PIS -EXT wrote: [...] > struct B > { > int numelem; > /* > * Old C trick to define a dynamically sizable array just by > allocating > * sizeof(B)

Re: [arch-general] gcc: loop do not terminate

2013-05-13 Thread Daniel Micay
On Mon, May 13, 2013 at 4:59 PM, LANGLOIS Olivier PIS -EXT wrote: >> >> The only time the switch makes a difference is when the program is already >> incorrect. I really doubt Arch is going to enable a flag slowing down all >> programs to make invalid programs behave >> *differently* (not necessar

Re: [arch-general] gcc: loop do not terminate

2013-05-13 Thread LANGLOIS Olivier PIS -EXT
> > The only time the switch makes a difference is when the program is already > incorrect. I really doubt Arch is going to enable a flag slowing down all > programs to make invalid programs behave > *differently* (not necessary as they were intended to behave, just > *differently*). > > GCC is cor

Re: [arch-general] gcc: loop do not terminate

2013-05-13 Thread Daniel Micay
On Mon, May 13, 2013 at 2:20 PM, LANGLOIS Olivier PIS -EXT wrote: > I have just been hit by something: > > lano1106@hpmini ~/dev/gcc-test $ g++ --version > g++ (GCC) 4.8.0 20130502 (prerelease) > Copyright (C) 2013 Free Software Foundation, Inc. > This is free software; see the source for copying

[arch-general] gcc: loop do not terminate

2013-05-13 Thread LANGLOIS Olivier PIS -EXT
I have just been hit by something: lano1106@hpmini ~/dev/gcc-test $ g++ --version g++ (GCC) 4.8.0 20130502 (prerelease) Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR