bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Is this a bug?


From: Hak-Jin Kim
Subject: Is this a bug?
Date: Mon, 12 Aug 2002 16:45:33 +0900

Hello!

Is there anyone who tell me if this is a bug?

I used gcc 2.95.4 and gcc 3.0.4 in Debian Woody.
My glibc library version is libc6 2.2.5-6


The following is my code.
=============================================================


#include <stdio.h>

size_t num_attributes=4;
size_t num_levels=4;
size_t num_segments=3;

int 
main()
{
        int i,j,k;
        double v_values[num_attributes][num_segments][num_levels];

        for (k=0; k<num_attributes; k++) {
                printf("(attributes %d)\n", k+1);
                for (i=0; i<num_segments; i++) {
                        for (j=0; j<=num_levels; j++) {
                                printf("  %u", &v_values[k][i][j]);
                        }
                        printf("\n");
                }
        }
        printf("\n");
        
        return 0;
}
================================================================

Its output is
=================================================================
(attributes 1)
  3221223476  3221223484  3221223492  3221223500  3221223508 <---
  3221223508  3221223516  3221223524  3221223532  3221223540 <---
  3221223540  3221223548  3221223556  3221223564  3221223572
(attributes 2)
  3221223572  3221223580  3221223588  3221223596  3221223604
  3221223604  3221223612  3221223620  3221223628  3221223636
  3221223636  3221223644  3221223652  3221223660  3221223668
(attributes 3)
  3221223668  3221223676  3221223684  3221223692  3221223700
  3221223700  3221223708  3221223716  3221223724  3221223732
  3221223732  3221223740  3221223748  3221223756  3221223764
(attributes 4)
  3221223764  3221223772  3221223780  3221223788  3221223796
  3221223796  3221223804  3221223812  3221223820  3221223828
  3221223828  3221223836  3221223844  3221223852  3221223860

==================================================================

What I found is allocated memories were overlapped.
See the 5th address in the second line is the same as the 1st column 
in the 3rd line.  This phenomenon appears on other lines in the same way.

Thanks,

Hak-Jin Kim



 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]