This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug sanitizer/66308] New: -fsanitize=alignment is missing "downcast of misaligned address" checks


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

            Bug ID: 66308
           Summary: -fsanitize=alignment is missing "downcast of
                    misaligned address" checks
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
                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
  Target Milestone: ---

GCC doesn't give any runtime error for this testcase:

struct node_base {
  char c;
};

struct node : node_base {
  long long l;
};

int main()
{
  unsigned char buf[sizeof(node_base)+1];
  node_base* n = (node_base*)(buf+1);
  (void) static_cast<node*>(n);
}

Clang says:

uba.cc:13:10: runtime error: downcast of misaligned address 0x7ffdd521f2eb for
type 'node', which requires 8 byte alignment
0x7ffdd521f2eb: note: pointer points here
 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  65 1d e2 36 32 00 00 00 
00 00 00 00 00 00 00
              ^


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]