Cの二次元配列の要素に0を代入したいのですが、store to misaligned addressというエラーが出ます。
c
1 int** list; 2 // int list[number + 1][limit + 1]; これを使いたかったが、エラーが出たためmallocを使用。 3 list = (int **)malloc(sizeof(int *) *( number+1)); 4 for( i = 0; i < number; i++) 5 { 6 list[i] = (int *)malloc(sizeof(int) * (limit+1)); 7 } 8 9 for(i = 0; i <= number; i++) 10 { 11 for(j = 0; j <= limit; j++) 12 { 13 if(i == 0 || j == 0) 14 { 15 list[i][j] =0; //<------この行でエラーが出る。 16 } 17 18 19
c
1runtime error: store to misaligned address 0xbebebebebebebebe for type 'int', which requires 4 byte alignment 20xbebebebebebebebe: note: pointer points here 3<memory cannot be printed> 4AddressSanitizer:DEADLYSIGNAL 5================================================================= 6==3081046==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x564902d9dcd9 bp 0x7ffe359b4b00 sp 0x7ffe359b4a00 T0) 7==3081046==The signal is caused by a READ memory access. 8==3081046==Hint: address points to the zero page. 9
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。