0

I wrote a quick matrix multiplier in C. It compiles and runs fine on my MBA. When I compile and run on my schools Linux box though, I get stuck in an infinite loop.

This is my gcc compile

gcc -Wall prog1.c -o prog1

This is the version of gcc I have on my MBA

i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 
2336.11.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

This is the version of gcc on the schools server.

gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-3)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Here is a link to the code.

EDIT: Sorry! I get an infinite loop on the input verification. I've been using printf statements to debug my code but even still I have a hard time understanding why it gets stuck there. What happens is the for() on line 181 keeps looping after it encounters a '+' or '-'.

Sixteen command line parameters because it fills two matrices with 8 integers each.

I'm not absolutely positive it's a problem with different compilers or my code! I just figured that was it because I get expected results on my MBA but not on the Red Hat machine.

gh0st
  • 1,653
  • 3
  • 27
  • 59
  • 2
    _Where_ does it get stuck in an infinite loop? Without knowing that, it will be very hard to diagnose the problem. (It's almost certainly not a bug in gcc 4.4.7, but a bug in your code that you happen to get away with in one environment but not the other.) – abarnert Sep 25 '13 at 19:40
  • 3
    Firsr step: use a debugger to figure out where the infinite loop is happening. – Ernest Friedman-Hill Sep 25 '13 at 19:40
  • possible duplicate of [C program gives an output different on different compiler](http://stackoverflow.com/questions/5115628/c-program-gives-an-output-different-on-different-compiler) – Farouq Jouti Sep 25 '13 at 19:41
  • Sixteen command line parameters ? Interesting... – WhozCraig Sep 25 '13 at 19:43
  • 1
    Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance. – Mihai Maruseac Sep 25 '13 at 19:45
  • Rather than the wall of code, is there some reason you're not utilizing *both* ends of those pipes and just having the parent process *send* each child the respective row/col of the matrix multiplication they're responsible for? This would collapse all those launches into literally one for-loop. – WhozCraig Sep 25 '13 at 19:55
  • `char str[3]`? Really? – n. m. could be an AI Sep 25 '13 at 20:25

0 Answers0