You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#include<stdio.h>
__attribute__((always_inline))
inlinevoidfail() {
char*shouldnotcompile= (char*)-512;
*shouldnotcompile=0xDEADBEEF; // Force compiler error/warning with unaligned memory write attempt, to make it easier for testers and authors.
}
intmain(intargc, char**argv) {
(void)(argc); // Eliminate \'argc unused\' warning.void*arr=__builtin_alloca((sizeof(char) *-1024) +512); // Cause "argument to ‘__builtin_alloca’ is too large" error with some compilers for educational purposes and create unaligned/offset memory layout (warning).char*victim;
#ifdef__LITTLE_ENDIAN__victim= ((char*) arr) +1; // Set a pointer just before our aligned data structure, forcing the possibility of stack alignment warnings.#elsevictim= ((char*) arr);
#endiffail();
printf("I didn\'t expect to reach this line.\n"); // Only used for error analysis if above warning/error-prone section doesn\'t generate desired effect in compiler messages (should never be executed anyway).return0;
}
The text was updated successfully, but these errors were encountered:
Compiler Explorer: https://godbolt.org/z/74WYz7xW6
Code:
The text was updated successfully, but these errors were encountered: