CTSRD-CHERI / llvm-project

Fork of LLVM adding CHERI support
49 stars 44 forks source link

Capability to array decays to 64-bit pointer when an offset is added #526

Closed kevin-brodsky-arm closed 3 years ago

kevin-brodsky-arm commented 3 years ago

In hybrid, adding an offset to a capability pointer to an array in a struct (s->array + 5) causes the pointer to decay to 64-bit. On the other hand, taking the address of an element (&s->array[5]) behaves as expected.

Here is a minimal reproducer,l:'5',n:'0',o:'C+source+%231',t:'0')),k:51.74603174603175,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((g:!((h:compiler,i:(compiler:morello-hybrid,filters:(b:'0',binary:'1',commentOnly:'0',demangle:'0',directives:'0',execute:'1',intel:'0',libraryCode:'0',trim:'1'),fontScale:14,fontUsePx:'0',j:1,lang:___c,libs:!(),options:'-O2+-Wall',selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'Hybrid+Morello+(Editor+%231,+Compiler+%231)+C',t:'0')),k:48.25396825396825,l:'4',m:50,n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compiler:1,editor:1,fontScale:10,fontUsePx:'0',wrap:'1'),l:'5',n:'0',o:'%231+with+Hybrid+Morello',t:'0')),header:(),l:'4',m:50,n:'0',o:'',s:0,t:'0')),k:48.25396825396825,l:'3',n:'0',o:'',t:'0')),l:'2',n:'0',o:'',t:'0')),version:4).

jrtc27 commented 3 years ago

Hm, that's an old known issue. I thought we had an issue filed already for it, but I can't seem to find it, maybe it was just a conversation on our Slack a while ago.