Re: gcc -O2 error

2008-03-23 Thread Mikael Ikivesi
On Sat, 22 Mar 2008 19:39:32 +0100
Kris Kennaway [EMAIL PROTECTED] wrote:
 So, did you consider perhaps following this advice? ;-)
 
 Kris
 

Yes I did.

The reason I send to this list also is that in make.conf manual says:

CFLAGS(str) Controls the compiler setting when compiling C code.
   Optimization levels other than -O and -O2 are not
sup- ported.


That means that -O2 should be supported in FreeBSD. And now it happens
to produce bad code.

GCC people think that this should be fixed in gcc 4.3.
I have not yet installed and verified that. However I tried the code
with linux installation with gcc 4.1.2 and it was ok.

As I don't known if gcc has some maintaining done in FreeBSD tree by
patching or just by integrating the next snapshot from time to time.
So I just though to report it in case that maintainers of
FreeBSD version of gcc might want to take a look at this.


-Mikael

___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: gcc -O2 error

2008-03-23 Thread Kris Kennaway

Mikael Ikivesi wrote:

On Sat, 22 Mar 2008 19:39:32 +0100
Kris Kennaway [EMAIL PROTECTED] wrote:

So, did you consider perhaps following this advice? ;-)

Kris



Yes I did.

The reason I send to this list also is that in make.conf manual says:

CFLAGS(str) Controls the compiler setting when compiling C code.
   Optimization levels other than -O and -O2 are not
sup- ported.


That means that -O2 should be supported in FreeBSD. And now it happens
to produce bad code.

GCC people think that this should be fixed in gcc 4.3.
I have not yet installed and verified that. However I tried the code
with linux installation with gcc 4.1.2 and it was ok.

As I don't known if gcc has some maintaining done in FreeBSD tree by
patching or just by integrating the next snapshot from time to time.
So I just though to report it in case that maintainers of
FreeBSD version of gcc might want to take a look at this.


-Mikael




The latter.  When the gcc people fix it, if there is a patch that 
applies to 4.2 then we could import it.


Kris
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: gcc -O2 error

2008-03-23 Thread Jeremy Chadwick
On Sat, Mar 22, 2008 at 07:24:33PM +0200, Mikael Ikivesi wrote:
 #include wchar.h
 #include stdio.h
 
 #define max_word_len64
 
 wchar_t *wrong(wchar_t *wordlist, wchar_t *word)
 {   wchar_t buffer[max_word_len+2];
 buffer[max_word_len+2]=0;
 
   STRIPPED PART
 
 if(wcsstr(wordlist,buffer)==0) wcscpy(wordlist,buffer);
 
   STRIPPED PART
 
 return wordlist;
 }

There's an off-by-one error in your code, which is very likely tickling
a bug in gcc.

That said, gcc shouldn't crash or be generating working code depending
upon which optimisation flags you use, so as Kris said, file a bug with
the gcc team for that.

-- 
| Jeremy Chadwickjdc at parodius.com |
| Parodius Networking   http://www.parodius.com/ |
| UNIX Systems Administrator  Mountain View, CA, USA |
| Making life hard for others since 1977.  PGP: 4BD6C0CB |

___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: gcc -O2 error

2008-03-23 Thread Mikael Ikivesi
On Sun, 23 Mar 2008 04:58:01 -0700
Jeremy Chadwick [EMAIL PROTECTED] wrote:
 
 There's an off-by-one error in your code, which is very likely
 tickling a bug in gcc.

Thanks..
I know...took me a while to find it.
And as code still seemed to work when built without -O2 it was hard
to spot. I sent bug report to gcc team as the -O2 did bork it,
regardless of my buggy coding :)


-Mikael

___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: gcc -O2 error

2008-03-23 Thread Jeremy Chadwick
On Sun, Mar 23, 2008 at 09:27:45PM +0200, Mikael Ikivesi wrote:
 On Sun, 23 Mar 2008 04:58:01 -0700
 Jeremy Chadwick [EMAIL PROTECTED] wrote:
  
  There's an off-by-one error in your code, which is very likely
  tickling a bug in gcc.
 
 Thanks..
 I know...took me a while to find it.
 And as code still seemed to work when built without -O2 it was hard
 to spot. I sent bug report to gcc team as the -O2 did bork it,
 regardless of my buggy coding :)

Thumbs up!  :-)  Despite the error, gcc still shouldn't behave that way,
so I do hope they fix it.

-- 
| Jeremy Chadwickjdc at parodius.com |
| Parodius Networking   http://www.parodius.com/ |
| UNIX Systems Administrator  Mountain View, CA, USA |
| Making life hard for others since 1977.  PGP: 4BD6C0CB |

___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


gcc -O2 error

2008-03-22 Thread Mikael Ikivesi
Hi

I am running uptodate RELENG_7. It has gcc (GCC) 4.2.1 20070719
[FreeBSD].

I tried to track down segfaults from my code and I accidentaly found a
optimization error. Code did not segfault when compiled without
optimization but crashed when -O2 was used.

I tried to track it I could make the gcc give me following error by
simply stripping few lines:

---
wrong.c: In function 'wrong':
wrong.c:11: error: Attempt to delete prologue/epilogue insn:
(insn/f 47 46 48 2 (set (mem:SI (plus:SI (reg/f:SI 6 bp)
(const_int -8 [0xfff8])) [0 S4 A8])
(reg:SI 3 bx)) -1 (nil)
(nil))
wrong.c:11: internal compiler error: in propagate_one_insn, at
flow.c:1735 Please submit a full bug report,
with preprocessed source if appropriate.
See URL:http://gcc.gnu.org/bugs.html for instructions.

--


And this is what triggers it:


#include wchar.h
#include stdio.h

#define max_word_len64

wchar_t *wrong(wchar_t *wordlist, wchar_t *word)
{   wchar_t buffer[max_word_len+2];
buffer[max_word_len+2]=0;

STRIPPED PART

if(wcsstr(wordlist,buffer)==0) wcscpy(wordlist,buffer);

STRIPPED PART

return wordlist;
}





-Mikael

___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: gcc -O2 error

2008-03-22 Thread Kris Kennaway

Mikael Ikivesi wrote:

Hi

I am running uptodate RELENG_7. It has gcc (GCC) 4.2.1 20070719
[FreeBSD].

I tried to track down segfaults from my code and I accidentaly found a
optimization error. Code did not segfault when compiled without
optimization but crashed when -O2 was used.

I tried to track it I could make the gcc give me following error by
simply stripping few lines:

---
wrong.c: In function 'wrong':
wrong.c:11: error: Attempt to delete prologue/epilogue insn:
(insn/f 47 46 48 2 (set (mem:SI (plus:SI (reg/f:SI 6 bp)
(const_int -8 [0xfff8])) [0 S4 A8])
(reg:SI 3 bx)) -1 (nil)
(nil))
wrong.c:11: internal compiler error: in propagate_one_insn, at
flow.c:1735 Please submit a full bug report,
with preprocessed source if appropriate.
See URL:http://gcc.gnu.org/bugs.html for instructions.


So, did you consider perhaps following this advice? ;-)

Kris

___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]