Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #388642

Re: c initialization algorithm

From Tim Rentsch <tr.17687@z991.linuxsc.com>
Newsgroups comp.lang.c
Subject Re: c initialization algorithm
Date 2024-10-13 22:00 -0700
Organization A noiseless patient Spider
Message-ID <86cyk3xoqw.fsf@linuxsc.com> (permalink)
References <vehee7$r8ri$1@dont-email.me> <20241013163050.897@kylheku.com>

Show all headers | View raw


Kaz Kylheku <643-408-1753@kylheku.com> writes:

> On 2024-10-13, Thiago Adams <thiago.adams@gmail.com> wrote:
>
>> The algorithm for C initialization as described in the standard
>> and implemented in gcc allow this.
>>
>> struct X{
>>      int a,b,c;
>> };
>>
>> int main()
>> {
>>      struct X x = {.a=1,2,3,.a=1, 2, 3};
>> }
>>
>> https://godbolt.org/z/7naedbEM6
>>
>> Basically, when a designed initializer is found the "cursor" goes
>> to that member and the following members are initialized in
>> order.
>
>  I do not suspect that therw is an observable order.  I.e. as
>  in a required order considered observable behavior.

Have you checked to C standard to see what it says about that?

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

c initialization algorithm Thiago Adams <thiago.adams@gmail.com> - 2024-10-13 18:35 -0300
  Re: c initialization algorithm Kaz Kylheku <643-408-1753@kylheku.com> - 2024-10-13 23:33 +0000
    Re: c initialization algorithm Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-10-13 22:00 -0700
      Re: c initialization algorithm Thiago Adams <thiago.adams@gmail.com> - 2024-10-14 08:14 -0300
        Re: c initialization algorithm Thiago Adams <thiago.adams@gmail.com> - 2024-10-15 08:12 -0300
          Re: c initialization algorithm Thiago Adams <thiago.adams@gmail.com> - 2024-10-15 08:14 -0300
            Re: c initialization algorithm Kaz Kylheku <643-408-1753@kylheku.com> - 2024-10-15 20:30 +0000

csiph-web