|
|
|
|
|
by ncruces
53 days ago
|
|
Do you always run with those sanitizers in place? Just this week I've had a C compilers silently delete me an entire function call because of UB (infinite loop without side effects). Took me a day to figure out. So that's a problem for me. I don't think I've ever had an hard to debug issue in Go because of signed/unsigned wrap around. Particularly a memory issue. If anything, and there I guess I agree with the article, I wish Go had implicit conversions to wider types: to make the problematic ones stand out. I guess the reason it doesn't is that they're different named types, which would be a problem when you create a named type for the purpose of forcing explicit type conversions. But maybe the default ones could implicitly implement a numeric tower, where exact conversions can be implicit. |
|
Regarding infinite loops, C++ and C differ with C++ being more aggressive. But also compilers differ with clang being more aggressive. https://godbolt.org/z/Moe6zYKqo
In general, I do not recommend to use clang if you worry about UB. gcc is a bit more reasonable and also has better warnings.