I agree there should be a warning. But it is not trivial to teach a compiler when to warn or not to not generate too many false positives.
Not as good as warning, but UBSan catches this at run-time: https://godbolt.org/z/Mdjn7h8dj
Not as good as warning, but UBSan catches this at run-time: https://godbolt.org/z/Mdjn7h8dj