The question is pretty much in the title.
The code
void modify_str(char* str){
if(strlen(str) > 5) {
str[5] = 'x';
}
}
Will invoke undefined behavior if a string literal is passed as argument, i.e.:
modify_str("some text");
Or
char *str = "some text";
modify_str(str);
Is there any way to assert at runtime that a string passed as argument is not a string literal, but a modifiable string?