Hi,

how does noreturn attribute work? Trying to get this [0] to work, I 
error on noreturn.

/* Note how buffer overruns are undefined behavior and the compilers tend to
   optimize these checks away if you wrote them yourself, this only works
   robustly because the compiler did it itself. */
extern uintptr_t __stack_chk_guard;
noreturn void __stack_chk_fail(void);
void foo(const char* str)
{
        uintptr_t canary = __stack_chk_guard;
        char buffer[16];
        strcpy(buffer, str);
        if ( (canary = canary ^ __stack_chk_guard) != 0 )
                __stack_chk_fail();
}



main.c:7:10: error: expected ???=???, ???,???, ???;???, ???asm??? or 
???__attribute__??? before ???void???
 noreturn void __stack_chk_fail(void);

tried 
void __stack_chk_fail(void) __attribute ((noreturn));
instead.


[0]  http://wiki.osdev.org/Stack_Smashing_Protector

Reply via email to