(void)ing unreferenced parameters

Martin Dorey martin.dorey@madge.com
Fri Jun 18 03:56:00 GMT 1999


> Why is it that bugs which lie dormant for months suddenly pop out all
over the
> place?

Thanks, and indeed.  In fairness, I have been trying to post it for some
time, but the mail kept getting stuck.

> Describing a device's memory layout with a struct
> and then mapping it at a particular address I understand. Dinking
particular
> fields of that struct to strobe something I understand. I find it hard
to
> understand why you'd dink the *whole* struct in one go. But I'm not
suggesting
> gratuitously banning it.

Scenario: you want to read several registers from a device in a loop,
whose values all change each time you frob the device - once per loop
iteration.  You have to use volatile, to ensure the dereference doesn't
get hoisted out of the loop.  You can get the whole struct at once,
because you know the device's registers won't change except when you
frob it.  You want to get the whole struct at once, because sequential
memory accesses are more efficient, perhaps because of memory pipelining
or because the compiler might then be able to read several byte-wide
registers with a word-read.

Scenario: you want to save the whole state of the device in one go.
Again, you need to be sure that you're going to read a consistent state.

--




More information about the Gcc-bugs mailing list