Bug#96099: gcc bug(s)
On Wed, May 02, 2001 at 12:47:56PM -0600, dennis_josifovich@somerset-financial.com wrote:
> first
> dpkg --list | grep gcc
> yeilds
> ii gcc 2.95.3-7 The GNU C compiler.
> ii gcc-2.95 2.95.4-0.01042 The GNU C compiler.
>
> I'm not 100% sure why my system thinks both "gcc" and "gcc-2.95"
> are installed. Suggestions on how to fix this would be appreciated.
> I upgraded from a "stable" debian release to "testing" a month or
> so ago.
It's not a bug. Most platforms are using gcc 2.95, but some need
gcc 3.0. So gcc just depends on the default gcc for the platform,
which is gcc-2.95 in your case.
> >From a really bad piece of code I was looking at that had a bug
> in the code, leads me to believe there is also a compiler bug.
>
> {
> int
> arr[10][10],
> x,
> y;
>
> for (x = 0; x < 10; x++) {
> for (y = 0; y < 10; y++) {
> arr[x][y] = ((x = y) ? 1 : 0);
> printf("%d\n", arr[x][y]);
> }
> }
> }
>
> Don't ask where the code comes from, its not mine. The bug in
> the code is the "(x = y)" was susppose to be "(x == y)". But
> theoretically with the bug still in place I would expect arr[0][0],
> arr[1][1], ..., arr[9][9] to be the only elements filled in and
> arr[0][0] will contain 0 and the other arr[i][i] would contain 1.
When I first looked at your code, I thought that you were wrong,
because x gets set to y, then y gets incremented, then arr[x][y]
is chosen. Then I realized that that's not right, and there is no
specified answer. You're modifying x and y in the same line where
you use x and y. That's nasal demon area, and the compiler can do
whatever it wants on this code and still be standards complaint.
I don't think I can close bug, since I'm not one of the gcc
maintainers. But it's definetly closable.
--
David Starner - dstarner98@aasaa.ofe.org
Pointless website: http://dvdeug.dhis.org
"I don't care if Bill personally has my name and reads my email and
laughs at me. In fact, I'd be rather honored." - Joseph_Greg
Reply to: