On Tue, Mar 05, 2019 at 09:36:56PM +0100, David Brown wrote:
> On 05/03/2019 19:37, Segher Boessenkool wrote:
> >On Mon, Mar 04, 2019 at 09:45:37PM +0100, David Brown wrote:
> >>void foo(void) {
> >>     char key[20];
> >>     strcpy(key, "Top secret");
> >>     usekey(key);
> >>     memset(key, 0, sizeof(key));
> >>     {
> >>         typedef struct { char x[20]; } XS;
> >>         XS *p = (XS *) key;
> >>         asm("" : "+m" (*p));
> >>     }
> >>}
> >
> >You need to use "asm volatile" here.  In principle GCC can see all the
> >outputs of the asm are dead and delete all of the asm, otherwise.  But
> >you don't need an output for *p (or inout as you wrote), just an input
> >is fine.
> 
> There are no outputs from this asm - only an input.

"+m" is an output.  There is only one colon before it, and besides, "+"
is only allowed on outputs.


Segher

Reply via email to