public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/97424] New: Warn on invalid shift amount after inlining
@ 2020-10-14 16:02 fw at gcc dot gnu.org
  2020-10-14 16:45 ` [Bug tree-optimization/97424] " jakub at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: fw at gcc dot gnu.org @ 2020-10-14 16:02 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-12-26 16:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-14 16:02 [Bug tree-optimization/97424] New: Warn on invalid shift amount after inlining fw at gcc dot gnu.org
2020-10-14 16:45 ` [Bug tree-optimization/97424] " jakub at gcc dot gnu.org
2020-10-14 16:48 ` fw at gcc dot gnu.org
2020-10-14 17:16 ` dmalcolm at gcc dot gnu.org
2020-10-15  6:00 ` rguenth at gcc dot gnu.org
2020-11-12  2:18 ` cvs-commit at gcc dot gnu.org
2020-11-12 14:03 ` dmalcolm at gcc dot gnu.org
2020-11-27 19:11 ` fw at gcc dot gnu.org
2020-12-26 16:41 ` vincent-gcc at vinc17 dot net

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).