mirror / tinycc

http://repo.or.cz/tinycc.git

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

why tcc allows stdlib to mutate constant value?

bokunodev opened this issue · comments

this code is totally wrong. but its run anyway.

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char const *argv[]) {
  char *line; //= calloc(1 << 20, sizeof(char));
  FILE *f = fopen("input", "r");
  for (int i = 0; i < 11; i++) {
    line = fgets("\r\n", 1 << 20, f);
    if (!line) {
      break;
    }
    printf("%s line", line);
  }
  return 0;
}