public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/44681]  New: usage of macro in loop boundary leads to crash
@ 2010-06-26 13:26 jd at cococo dot de
  2010-06-27 23:21 ` [Bug middle-end/44681] " pinskia at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: jd at cococo dot de @ 2010-06-26 13:26 UTC (permalink / raw)
  To: gcc-bugs

When porting my software from Win32 to Linux, i had to recompile it with gcc
under Mingw and also under Linux. There was a hurdle, because the loop shown
below in b) crashed after a while on both platforms. (I was happy to find the
location of the bug with gdb!) After rearranging the code like c) it worked
properly.
Sorry, but i am not able to provide test data. Maybe someone will see at once,
where the problem is located.

Greetings
Jens
http://cococo.de

a) prerequisite
#define max(a,b)            a>b?a:b

b) buggy variant (for loop in line 13)
//------------------------------------------------------------------------------
//copy column left to right
//------------------------------------------------------------------------------
void copyvector(Tree pre,Tree left,int lc,Tree right,int rc) {
  int nr;
  callsofcopyvector++;
  //check initialization of precondition
  defval(left,right,rc,coeff(left,0,lc));
  right->functype=left->functype;
  right->bordertype=left->bordertype;
  right->symtype=left->symtype;
  right->reversive=left->reversive;
  for (nr=0;nr <= max(left->rows,right->rows);nr++) {//now do composition of
functions
         if (nr <= right->rows)
                asg(right,nr,rc,0);
         if ((nr <= left->rows) && (nr <= right->rows)) {
                Tree ur=coeff(left,nr,lc);
                //debug(coeff(left,nr,0))
                asg(right,nr,rc,ur);
         }
  }
  asg(right,0,rc,pre);
  checkunreachable(right,right,rc);
  return;
}
c) working variant
//------------------------------------------------------------------------------
//copy column left to right
//------------------------------------------------------------------------------
void copyvector(Tree pre,Tree left,int lc,Tree right,int rc) {
  int nr,mav=max(left->rows,right->rows);
  callsofcopyvector++;
  //check initialization of precondition
  defval(left,right,rc,coeff(left,0,lc));
  right->functype=left->functype;
  right->bordertype=left->bordertype;
  right->symtype=left->symtype;
  right->reversive=left->reversive;
  for (nr=0;nr <= mav;nr++) {//now do composition of functions
         if (nr <= right->rows)
                asg(right,nr,rc,0);
         if ((nr <= left->rows) && (nr <= right->rows)) {
                Tree ur=coeff(left,nr,lc);
                //debug(coeff(left,nr,0))
                asg(right,nr,rc,ur);
         }
  }
  asg(right,0,rc,pre);
  checkunreachable(right,right,rc);
  return;
}


-- 
           Summary: usage of macro in loop boundary leads to crash
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: blocker
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jd at cococo dot de


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44681


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-07-01  5:37 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-26 13:26 [Bug c/44681] New: usage of macro in loop boundary leads to crash jd at cococo dot de
2010-06-27 23:21 ` [Bug middle-end/44681] " pinskia at gcc dot gnu dot org
2010-06-27 23:23 ` pinskia at gcc dot gnu dot org
2010-06-27 23:31 ` redi at gcc dot gnu dot org
2010-06-30 10:32 ` jd at cococo dot de
2010-06-30 10:57 ` redi at gcc dot gnu dot org
2010-06-30 13:44 ` jd at cococo dot de
2010-06-30 14:16 ` redi at gcc dot gnu dot org
2010-06-30 16:47 ` jd at cococo dot de
2010-06-30 17:10 ` redi at gcc dot gnu dot org
2010-07-01  5:37 ` jd at cococo dot de

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).