Initializer as Full Expression

S

Shao Miller

I've noticed that each initializer is a full expression with a sequence
point at its end in C1X. But the order of evaluation and side effects
are also unspecified. Are these unsequenced or indeterminately
sequenced? Is each initializer in an initializer-list a full
expression, separate from its peer initializers? If so, what can we
expect from:

int i = 1;
struct foo {
int j;
int k;
} bar = { ++i, i + 5 };

?

My preference would be for indeterminately sequenced. ;) Thanks for any
insight.

- Shao Miller
 
S

Shao Miller

Shao said:
I've noticed that each initializer is a full expression with a sequence
point at its end in C1X. But the order of evaluation and side effects
are also unspecified. Are these unsequenced or indeterminately
sequenced? Is each initializer in an initializer-list a full
expression, separate from its peer initializers? If so, what can we
expect from:

int i = 1;
struct foo {
int j;
int k;
} bar = { ++i, i + 5 };

?

My preference would be for indeterminately sequenced. ;) Thanks for any
insight.

- Shao Miller
To be clear, please allow me to change that:

int i = 1;
struct foo {
int j;
int k;
} bar = { .j = ++i, .k = i + 5 };
 
S

Shao Miller

To be clear, please allow me to change that:

int i = 1;
struct foo {
   int j;
   int k;

} bar = { .j = ++i, .k = i + 5 };
Oops! Keith already mentioned this in another thread!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top