[Bug c/50996] New: segfault cross-compiling for lm32

2011-11-05 Thread rubini at gnudd dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50996

 Bug #: 50996
   Summary: segfault cross-compiling for lm32
Classification: Unclassified
   Product: gcc
   Version: 4.6.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: rub...@gnudd.com


Created attachment 25728
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25728
Minimal file that causes the segfault

This may be similar to bug 50927 and maybe 46898.

The compiler segfault on an apparently simple (but ugly) newlib file.
I removed command line options from the complete command to get
the minimum failing case. I also trimmed the preprocessed file
to the minimum, thich I attach.

The original file is envz-entry.c for newlib 1.18.0 or 1.19.0.
The same segfault happens with 4.6.1 and 4.6.2

With -O1 it segfaults like with -O2 (which I got in my log file).

spusa$ /data/spusa/lm32/build-05-17-10/./gcc/xgcc
-B/data/spusa/lm32/build-05-17-10/./gcc/   -O1 -c /tmp/x.c
xgcc: internal compiler error: Segmentation fault (program cc1)
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.


[Bug c/50996] segfault cross-compiling for lm32

2011-11-05 Thread rubini at gnudd dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50996

--- Comment #1 from Alessandro Rubini  2011-11-05 
17:20:41 UTC ---

I removed more stuff. What follows is the minimal file that triggers
the error. Swapping the && operands won't make it segfault



void
envz_entry(char *envz)
{
  char *buf_ptr = (char *)envz;

  while(1)
  while(*buf_ptr && buf_ptr != envz)
  buf_ptr--;
}