CTSRD-CHERI / clang

DO NOT USE. Use llvm-project instead
Other
9 stars 8 forks source link

cheri_ccallee attribute conflict #99

Closed hbcam closed 8 years ago

hbcam commented 8 years ago

Testcase: (a.c)

__attribute__((cheri_ccallee)) void malloc(void);

The name malloc is important here.

Command:

clang --target=cheri-unknown-freebsd -mabi=sandbox -fcolor-diagnostics -c a.c

Result:

a.c:1:37: error: function declared 'cheri_ccallee' here was previously declared without calling convention
__attribute__((cheri_ccallee)) void malloc(void);
                                    ^
a.c:1:37: note: previous declaration is here
1 error generated.
davidchisnall commented 8 years ago

Does this work with all functions, or just ones that are part of the C specification? I suspect that it's a bad idea to add attributes on standard library functions, as it's undefined behaviour in C (programs are allowed to declare void *malloc() without including headers and so having mismatched calling conventions would be Very Bad™.

hbcam commented 8 years ago

It only happens with some stl functions (malloc-related, printf-related, exit, maybe more). I will avoid those names. Might be worth improving the error message?

davidchisnall commented 8 years ago

The error message is not very informative, but this is caused by providing a definition of a standard function that conflicts with the definition from the standard. Doing so is undefined behaviour.