CTSRD-CHERI / clang

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

implicit promotions of references to integers should ignore sign #195

Closed brooksdavis closed 6 years ago

brooksdavis commented 6 years ago
.../git/cheribsd/sys/kern/kern_umtx.c:998:27: error: cannot implicitly  
      or explicitly convert non-capability type 'unsigned long *' to unrelated  
      capability type 'long * __capability'                                     
                error = fueword_c(addr, &tmp);                                  

In this case, fueword_c is called with a mix if signs and since it's doing ld it's not actually doing anything sign-dependent. I can work around this with casts but there are going to be a lot of them.

khilangudka commented 6 years ago

Currently the non-CHERI behaviour for clang is to output a warning (-Wpointer-sign). Would it be OK to output a warning when doing this sort of capability promotion so that it is consistent?

The -Wpointer-sign warning is also what is output in the purecap ABI:

test.c:3:23: warning: initializing 'long * __capability' with an expression of type 'unsigned long * __capability' converts between pointers to integer
      types with different sign [-Wpointer-sign]
brooksdavis commented 6 years ago

That could work since we could suppress the warning when we don't want it.

khilangudka commented 6 years ago

We also don't currently support promotion in the same-signed case or more generally where the pointee types are the same. Is this something that we should be allowing? Or allow but output a warning?

brooksdavis commented 6 years ago

In case the implied context wasn't clear, the warning is on the &tmp. I'd tried changing that argument to be a capability for consistency.