gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu9)
Target: x86_64-linux-gnu
Resulting binary crushes with segmentation fault if gcc compile options include
-O3.
Source code:
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
void process_buf(uint32_t *buf)
{
int i;
uint32_t t = 0;
for(i = 0; i < 16; i++)
buf[i] = ++t; // segmentation fault
}
int main(int argc, char **argv)
{
char *buf = malloc(65);
int n;
process_buf((uint32_t*)(buf + 1));
n = write(1, buf + 1, 64);
return 0;
}
--
Summary: segmentation fault with -O3 when accessing byte-aligned
array as dwords
Product: gcc
Version: 4.4.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ajk dot xyz at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43009