4 ms·
> and all branches of an if statement must return a value. Is indeed a bit strange. I guess I can see the reasoning, though. "const by default" doesn't seem
by e12e 10y ago
> and all branches of an if statement must return a value.
Is indeed a bit strange. I guess I can see the reasoning, though.
"const by default" doesn't seem all that unreasonable to me - isn't that one of the major driving forces we're seeing in "new" languages - that based on years of experience, "accidental" mutability should be avoided -- mutability should not be the default?
How does this subsetting of C affect the error messages the students are (most) likely to see? Does -Wall typically catch treating a const as mutable? (I assume so, I'm just curious about this, as I'll soon be teaching a beginning programming course - and a sub-set of C might be an interesting option).
- michaelmior 10y agoWe are pretty liberal with the warnings. -Wall will catch trying to mutate const variables. We also use address sanitizer[0] with clang which helps a lot with common memory errors. All this makes the code run (relatively) quite slow but since anything they're testing should complete in a few seconds regardless, it's not a problem for us in practice. [0] http://clang.llvm.org/docs/AddressSanitizer.html http://clang.llvm.org/docs/AddressSanitizer.html