This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug sanitizer/66308] New: -fsanitize=alignment is missing "downcast of misaligned address" checks
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 27 May 2015 15:12:34 +0000
- Subject: [Bug sanitizer/66308] New: -fsanitize=alignment is missing "downcast of misaligned address" checks
- Auto-submitted: auto-generated
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
^