This question already has an answer here:
I am doing some tests and accidentally forgot return statement.
However the code still works correctly. Here are simplified code that still works.
#include <stdio.h>
#include <string.h>
char *mydup(){
char *copy = new char[6];
memcpy(copy, "abcde", 6);
}
int main(){
printf("%s\n", mydup());
return 0;
}
If I compile with -Wall, i get warning:
x1.cc:7:1: warning: no return statement in function returning non-void [-Wreturn-type]
How this works at all???
I am using gcc on 64bit Linux.
Aucun commentaire:
Enregistrer un commentaire