atom feed25 messages in org.freebsd.freebsd-portsRe: reasons for rewriting regular memory
FromSent OnAttachments
Roman DivackyJul 25, 2011 8:58 am 
Diane BruceJul 25, 2011 10:06 am 
George LiaskosJul 25, 2011 12:06 pm 
Matthias AndreeJul 25, 2011 2:53 pm 
Raphael Kubo da CostaJul 25, 2011 4:30 pm 
Chuck SwigerJul 25, 2011 4:58 pm 
Florent ThoumieJul 26, 2011 1:24 am 
Gerald PfeiferSep 3, 2011 8:08 pm 
Ruslan MahmatkhanovSep 3, 2011 11:41 pm 
Ivan KlymenkoSep 4, 2011 12:12 am 
Matthias AndreeSep 4, 2011 12:26 am 
Michel TalonSep 4, 2011 12:29 am 
Matthias AndreeSep 4, 2011 12:32 am 
Matthias AndreeSep 4, 2011 12:34 am 
Ivan KlymenkoSep 4, 2011 1:45 am 
Mark LinimonSep 4, 2011 1:48 am 
Matthias AndreeSep 4, 2011 3:22 am 
Matthias AndreeSep 4, 2011 3:24 am 
Bob EagerSep 4, 2011 5:06 am 
Matthias AndreeSep 4, 2011 6:31 am 
per...@pluto.rain.comSep 4, 2011 7:13 pm 
Ruslan MahmatkhanovSep 5, 2011 4:42 am 
Ruslan MahmatkhanovSep 5, 2011 4:45 am 
Matthias AndreeSep 5, 2011 9:43 am 
Oliver FrommeSep 5, 2011 1:19 pm 
Subject:Re: reasons for rewriting regular memory
From:Matthias Andree (matt@gmx.de)
Date:Sep 5, 2011 9:43:22 am
List:org.freebsd.freebsd-ports

Am 05.09.2011 11:09, schrieb per@pluto.rain.com:

Matthias Andree <matt@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; }