This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Bug in C++ tree inlining or in PPC backend?


Hi Mark,

the appended testcase (derived from testsuite/tstring.cc) generates an endless
output loop in cattest()/cout on powerpc-linux-gnu, if compiled with -O1.
Z is output correctly, but it seems the string length got corrupted (the
testsuite happily filled my disk with GBytes :-) ).
Higher optimization levels fix the problem and I tracked it down to the
-fstrict-aliasing switch. The main difference between the -O1 and -O1
-fstrict-aliasing compiled files are the assigned stack slots (the ones
assigned to QImode MEM are looking most suspicious to me).

I strongly believe that started with the enabling of tree based inlining (but
I'm not 100% sure), but currently I'm lost in debugging this. Do you have any
hints for me on how to continue?

BTW, this little patch fixes it, but I don't believe its correct:

Index: function.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/function.c,v
retrieving revision 1.146
diff -u -p -r1.146 function.c
--- function.c  2000/01/01 00:07:54     1.146
+++ function.c  2000/01/02 13:43:20
@@ -662,8 +662,8 @@ assign_stack_temp_for_type (mode, size,
   for (p = temp_slots; p; p = p->next)
     if (p->align >= align && p->size >= size && GET_MODE (p->slot) == mode
        && ! p->in_use
-       && (!flag_strict_aliasing
-           || (alias_set && p->alias_set == alias_set))
+       && (/*!flag_strict_aliasing
+           ||*/ (alias_set && p->alias_set == alias_set))
        && (best_p == 0 || best_p->size > p->size
            || (best_p->size == p->size && best_p->align > p->align)))
       {


Franz.

#include <string>
#include <algorithm>
#include <iostream.h>
#include <stdlib.h>

string X = "Hello";
string Y = "world";
string N = "123";
string c;
const char*  s = ",";

void cattest()
{
  string x;
  string y;
  string z;

  x = X;
  y = Y;
  z = x + s + ' ' + y.substr (y.find ('w'), 1) + y.substr (y.find ('w') + 1) + ".";
  cout << "z = x + s +  + y.substr (y.find (w), 1) + y.substr (y.find (w) + 1) + . = " << z << "\n";
}


int main()
{
  cattest();
  cout << "\nEnd of test\n";
  return 0;
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]