This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug sanitizer/81598] -fsanitize=enum does not detect range violation
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 03 Aug 2017 11:13:24 +0000
- Subject: [Bug sanitizer/81598] -fsanitize=enum does not detect range violation
- Auto-submitted: auto-generated
- References: <bug-81598-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81598
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The extra instrumention should be on NOP_EXPR/CONVERT_EXPR (dunno about
VIEW_CONVERT_EXPR) from some type to enum type if the from type isn't the same
enum type or some type with equal min/max values. But given that we consider
such conversions useless:
/* If both the inner and outer types are integral types, then the
conversion is not necessary if they have the same mode and
signedness and precision, and both or neither are boolean. */
we'd need to instrument that early (either during genericization, or
gimplification at latest). It could be done by turning the check into some ifn
and lowering it later (sanopt) of course.