Am 05.09.2011 11:09, schrieb per...@pluto.rain.com:
> Matthias Andree <matthias.and...@gmx.de> wrote:
>>> I agree, but I can think of another valid exception. System with
>>> Hamming correction on the memory, gets a single bit (correctable)
>>> error. Need to rewrite the memory contents to reset all the parity
>>> bits!
>> That's a matter of the EDAC stuff, not the business of applications.
> 
> True, but it may explain why clang does not flag "*x = *x;" when it
> does flag "x = x;".  A compiler cannot know the context in which the
> compiled code will be used.

And a compiler is free to optimize either away unless the storage class
is "volatile", so the original point stands:

> BTW I agree that an understanding is needed of _why_ the code in
> question was included.  

Which waits on the original author.

On the other issue:

> I have seen "x = x;" -- x being a formal
> parameter -- used to prevent an "unused argument" warning in a
> function which did not in fact need the argument in question, but
> had to declare it for uniformity with other functions pointed to
> by the same function pointer type.

The portable and concise solution is to cast unused arguments to void,
as in this example:

int f(int used, int unused) {
  (void)unused; // avoids warnings

  // ...
  // now do something with used
  // ...

  return 42;
}
_______________________________________________
freebsd-ports@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"

Reply via email to