08-08-2018, 03:51 AM
13.1 indicates that an initializer list shall not contain persistent side effects, and gives an example of initializing with a volatile variable access. I believe there would be general agreement that
does not count as an "access" and is therefore compliant.
What about address of submembers of a volatile aggregate?
Our cross-compiler defines our microconroller's memory mapped registers by address, like so:
Are either of the members of this initializer list complaint?
Code:
volatile uint16_t v1;
volatile uint16_t *a[1] = {&v1};
What about address of submembers of a volatile aggregate?
Code:
struct foo
{
uint16_t bar;
};
volatile struct foo baz;
volatile uint16_t *a[1] = {&baz.bar};
Our cross-compiler defines our microconroller's memory mapped registers by address, like so:
Code:
struct foo
{
uint16_t bar;
};
#define REG1 (*(volatile uint16_t *)0x100)
#define REG2 (*(volatile struct foo *)0x1000)
volatile uint16_t *a[2] = {®1, ®2.bar};
<t></t>