Skip to content

Array of structs initializer alignment inconsistent, depends on ordering. #1727

Open

Description

@droopycom

Input:

struct _s table[] = {
    {
        101,
        {},
	0
    },
    {
        105,
        {'str1'},
        1
    },
    {
        104,
        {'str1','str2'},
        2
    },
};

struct _s table2[] = {
    {
        104,
        {'str1','str2'},
        2
    },
    {
        105,
        {'str1'},
        1
    },
    {
        101,
        {},
	0
    },
};

Output:

struct _s table[] = {
    {
        101,
        {        },
        0
    },
    {
        105,
        { 'str1' },
        1
    },
    {
        104,
        { 'str1', 'str2'},
        2
    },
};

struct _s table2[] = {
    {
        104,
        { 'str1', 'str2' },
        2
    },
    {
        105,
        { 'str1' },
        1
    },
    {
        101,
        {},
        0
    },
};

Expected result is no change in the empties '{}'.

debug.txt

Activity

  1. droopycom commented on Apr 26, 2018

    @droopycom
    Author

    Also inconsistent is that in table1 there is no space between 'str2' and }, but in table2 there is. And there is always a space between 'str1' and }

  2. changed the title [-]Array of structs initializer alignment unconsistent, depends on ordering.[/-] [+]Array of structs initializer alignment inconsistent, depends on ordering.[/+] on Apr 26, 2018
  3. guy-maurel commented on Apr 27, 2018

    @guy-maurel
    Contributor

    The problem is having a struct initializer inside a struct initializer inside something.
    uncrustify can't yet deal with that.
    The output are not predictable.

    Related to #967, #1293, #1349, #1601, #1727

  4. guy-maurel commented on Apr 4, 2019

    @guy-maurel
    Contributor

    The problem is having a struct initializer inside a struct initializer inside something.
    uncrustify can't yet deal with that.
    The output are not predictable.

    Related to #967, #1293, #1349, #1601, #1848

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions