https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63806

            Bug ID: 63806
           Summary: #UBSAN ignores signed char possible overflow
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: m.zakirov at samsung dot com
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    jakub at gcc dot gnu.org, kcc at gcc dot gnu.org

For the following example GCC with ubsan do not constructs UBSAN_ADD_CHECK for
signed char return value.

signed char a;
signed char b;

signed char foo ()
{
   return a + b;
}

Dump after ubsan

foo ()
{
  signed char a.0_2;
  unsigned char a.1_3;
  signed char b.2_4;
  unsigned char b.3_5;
  unsigned char _6;
  signed char _7;

  <bb 2>:
  a.0_2 = a;
  a.1_3 = (unsigned char) a.0_2;
  b.2_4 = b;
  b.3_5 = (unsigned char) b.2_4;
  _6 = a.1_3 + b.3_5;
  _7 = (signed char) _6;
  return _7;

}

Command line to reproduce

gcc -O3 t.c -fsanitize=signed-integer-overflow -fdump-tree-ubsan -S

Reply via email to