In the following test case (based on gcc.dg/tree-ssa/copy-headers.c),
the volatile asm statement is duplicated:

extern int foo (int);

void bla (void)
{
  int i, n = foo (0);

  for (i = 0; (({{  __asm__ volatile ("foo_label:"); }}), i < n); i++)
    foo (i);
}

In this case, this is problematic because it contains a label, which
means that assembly will fail.  (In other cases, there might be some
other magic that is adversely affected.)

The documentation of the asm keyword does not explicitly say that a
volatile asm statement may be duplicated by the compiler, but of
course it is to be expected in some cases (inlining, for example).
However, for consistency, it might be better to document that the
compiler may introduce duplicates in general (making my example
invalid).

What do you think?

Reply via email to