4 ms·
> I think they are referring to unions - probably writing to one union member but reading through another Thanks, you could be right. In that case, I think it
by quietbritishjim 6y ago
> I think they are referring to unions - probably writing to one union member but reading through another
Thanks, you could be right. In that case, I think it ought to be listed as a compile-time rather than a runtime error too (just as I already argued for null pointer dereference).
It depends a bit on use of course: if you have a function that takes an enum and considers all cases using pattern matching, then the compiler will stop you from accessing the wrong member within a given case. If you pass an enum to a function that expects one particular case to be active, then yes you can convert the compile time error into a run time one, but this is your own choice, not something that is naturally a run time error.