4 ms·
I guess you missed the word "modern"? Or are you saying you actually know of one?
by jcalvinowens 2y ago
I guess you missed the word "modern"? Or are you saying you actually know of one?
- dyhi55 2y agoSure, choose any platform before 1990. The modern ansi / iso c didn't exist before 1990. The c language is from 1970's. So code from any old tarball will assume c literals are writable, and will crash if not. It's a common complain when compiling old code, google it. The c standard library is full of functions that assume strings are writable: mktemp() sscanf() strtok() etc. Quote from gcc manual, explaining why you need to compile old code with -writable-strings option: "you cannot call mktemp with a string constant argument. The function mktemp always alters the string its argument points to. Another consequence is that sscanf does not work on some systems when passed a string constant as its format control string or input. This is because sscanf incorrectly tries to write into the string constant. Likewise fscanf and scanf."
- jcalvinowens 2y agoI define "modern" as ANSI/ISO C. That's pretty conservative IMO, I know people who call pre-C99 "legacy C"...
- kevin_thibedeau 2y agoMicrocontrollers running code loaded in RAM will have rodata linked into that RAM. Just takes an accidental cast to start writing them.
- jcalvinowens 2y agoTrue. All the more reason to make it an error, IMHO.