Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22310

Why this c code below works fine? (C Basic, Buffer overflow test)

$
0
0
#include <stdio.h>int main(int argc, char *argv[]){    int arr[5] = {1, 2, 3, 4, 5};    arr[6] = 7; // [1, 2, 3, 4, 5, 6]    printf("arr[6] = %d\n", arr[6]);    return 0;}

As I recall, it used to give a warning message when compiling and an unknown value when running.(Or I could see a Segment Fault message).

So I would like to know from which version the code above started working correctly.

My current GCC version is as follows:

gcc-13 (Homebrew GCC 13.2.0) 13.2.0Copyright (C) 2023 Free Software Foundation, Inc.This is free software; see the source for copying conditions.  There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Viewing all articles
Browse latest Browse all 22310

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>