Il 08/03/2013 19:04, Andrew Fish ha scritto:
>
>>> For GCC/clang, it is probably best to add
>>> -fno-delete-null-pointer-checks to the command line, because a
>>> NULL pointer dereference will not cause abnormal termination in
>>> TianoCore. The Linux kernel uses the same option.
>
> What we do is is add this flag to clang:
> -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang
>
> When clang optimizes undefined behavior away it will insert a ud2
> (trap on ARM) instruction. The -ftrap-function replaces the ud2
> instruction with a call to the function. This will give you a link
> error when your code contains undefined behavior. Do you know what
> gcc does in this case?
There's no similar option. GCC will just optimize the code as it sees
fit. As David pointed out, it means for example that (without the above
option):
int foo = *x;
if (!x)
return ERROR;
return foo;
will be optimized to simply "return *x".
Paolo
------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
endpoint security space. For insight on selecting the right partner to
tackle endpoint security challenges, access the full report.
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel