https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97424
Bug ID: 97424 Summary: Warn on invalid shift amount after inlining Product: gcc Version: unknown Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: fw at gcc dot gnu.org Target Milestone: --- Consider this program: #include <stdint.h> static inline uint32_t _dl_hwcaps_subdirs_build_bitmask (int subdirs, int active) { /* Leading subdirectories that are not active. */ int inactive = subdirs - active; if (inactive == 32) return 0; uint32_t mask; if (subdirs != 32) mask = (1 << subdirs) - 1; else mask = -1; return mask ^ ((1U << inactive) - 1); } void f1 (int); void f2 (void) { f1 (_dl_hwcaps_subdirs_build_bitmask (1, 2)); f1 (_dl_hwcaps_subdirs_build_bitmask (33, 31)); } This has invalid shifts involving a negative shift amount and larger-than-width shift amount. This does not result in a warning because the current shift warnings are implemented in the front end. But the computed values as the argument to f1 are garbage, so it would make sense to warn.