Re: gcc miscompiling duff's device (probaby two different bugs)

2010-03-04 Thread Peter Kourzanov
Dear all, Although I probably shouldn't have been so harsh calling this "mis-compiling", do you see any chance of back-porting this warning back into the mainline? P.S. The rationale of this exercise is of course that the "switch", being a goto in disguise needs careful attention, just like th

Re: gcc miscompiling duff's device (probaby two different bugs)

2010-03-02 Thread Peter Kourzanov
On Tue, 2010-03-02 at 12:26 +0100, Richard Guenther wrote: > On Tue, Mar 2, 2010 at 12:00 PM, Pjotr Kourzanov > wrote: > > On Tue, 2010-03-02 at 10:47 +, Andrew Haley wrote: > >> On 03/02/2010 10:34 AM, Pjotr Kourzanov wrote: > >> > >> >> int duff4_fails(char * dst,const char * src,const size

Re: gcc miscompiling duff's device (probaby two different bugs)

2010-03-02 Thread Richard Guenther
On Tue, Mar 2, 2010 at 12:00 PM, Pjotr Kourzanov wrote: > On Tue, 2010-03-02 at 10:47 +, Andrew Haley wrote: >> On 03/02/2010 10:34 AM, Pjotr Kourzanov wrote: >> >> >> int duff4_fails(char * dst,const char * src,const size_t n) >> >> { >> >>   const size_t rem=n % 4, a=rem + (!rem)*4; >> >>  

Re: gcc miscompiling duff's device (probaby two different bugs)

2010-03-02 Thread Pjotr Kourzanov
On Tue, 2010-03-02 at 10:47 +, Andrew Haley wrote: > On 03/02/2010 10:34 AM, Pjotr Kourzanov wrote: > > >> int duff4_fails(char * dst,const char * src,const size_t n) > >> { > >> const size_t rem=n % 4, a=rem + (!rem)*4; > >> char * d=dst+=a; > >> const char * s=src+=a; > >> /* gcc bu

Re: gcc miscompiling duff's device (probaby two different bugs)

2010-03-02 Thread Andreas Schwab
Peter Kourzanov writes: > I think the compiler is generating wrong code for duff4_fails() when > 'case 0' labels the for-loop. It somehow skips the first for-loop > expression, If rem != 0 you jump over the init expression, so it is never executed. Andreas. -- Andreas Schwab, sch...@redhat.

Re: gcc miscompiling duff's device (probaby two different bugs)

2010-03-02 Thread Andrew Haley
On 03/02/2010 10:34 AM, Pjotr Kourzanov wrote: >> int duff4_fails(char * dst,const char * src,const size_t n) >> { >> const size_t rem=n % 4, a=rem + (!rem)*4; >> char * d=dst+=a; >> const char * s=src+=a; >> /* gcc bug? dst+=n; */ >> >> switch (rem) { >> case 0: for(dst+=n;d>

Re: gcc miscompiling duff's device (probaby two different bugs)

2010-03-02 Thread Pjotr Kourzanov
On Tue, 2010-03-02 at 11:27 +0100, Richard Guenther wrote: > On Tue, Mar 2, 2010 at 10:38 AM, Peter Kourzanov > wrote: > > > > Hi guys, > > > > I have the following variation on Duff's device that seems to > > mis-compile on all GCC versions I can access within a minute (that > > is gcc-3.{3,4},

Re: gcc miscompiling duff's device (probaby two different bugs)

2010-03-02 Thread Pjotr Kourzanov
On Tue, 2010-03-02 at 10:24 +, Andrew Haley wrote: > On 03/02/2010 09:38 AM, Peter Kourzanov wrote: > > > I have the following variation on Duff's device that seems to > > mis-compile on all GCC versions I can access within a minute (that > > is gcc-3.{3,4}, gcc-4.{1,2,3,4} on x86 and gcc

Re: gcc miscompiling duff's device (probaby two different bugs)

2010-03-02 Thread Richard Guenther
On Tue, Mar 2, 2010 at 10:38 AM, Peter Kourzanov wrote: > > Hi guys, > >  I have the following variation on Duff's device that seems to > mis-compile on all GCC versions I can access within a minute (that > is gcc-3.{3,4}, gcc-4.{1,2,3,4} on x86 and gcc-4.3.2 on x86_64). The > symptoms are as foll

Re: gcc miscompiling duff's device (probaby two different bugs)

2010-03-02 Thread Andrew Haley
On 03/02/2010 09:38 AM, Peter Kourzanov wrote: > I have the following variation on Duff's device that seems to > mis-compile on all GCC versions I can access within a minute (that > is gcc-3.{3,4}, gcc-4.{1,2,3,4} on x86 and gcc-4.3.2 on x86_64). The > symptoms are as follows: > > $ gcc-4.4