Menu ▾ ▴

#593 Wrong indendation when returning struct

open-accepted
None
1 day ago
2025-03-21
Zenju
No

AStyle built from git 2025-03-21 code produces: (full repro when inside .cpp file)

FilterConfig getConfig()
{
    return
    {
        enumTimeDescr_.get(),
                      123
    };
}

the expected "class" indentation should be:

FilterConfig getConfig()
{
    return
    {
        enumTimeDescr_.get(),
        123
    };
}

using

--style=allman
--suffix=none
--keep-one-line-blocks
--align-pointer=type
--min-conditional-indent=0
--max-continuation-indent=80
--indent-switches
--indent-col1-comments
--indent-preproc-block
--indent-preproc-define
--pad-header
--pad-comma
--formatted
--lineend=linux
--indent-preproc-block
--convert-tabs
--preserve-ws

BTW thanks for your super-fast fixes recently! I'll be using Astyle 2025-03-21 in production now :)

Discussion

  • Zenju

    Zenju - 2025-03-21

    There is also the opposite case:

    AStyle produces:

    auto test()
    {
        return
        {
            .ai_flags = AI_ADDRCONFIG |
            AI_PASSIVE
        };
    }
    

    while the expected result is:

    auto test()
    {
        return
        {
            .ai_flags = AI_ADDRCONFIG |
                        AI_PASSIVE
        };
    }
    
     
  • André Simon

    André Simon - 2026-11-03

    This should be fixed in 3.6.21.

     
  • André Simon

    André Simon - 2026-11-03
    • status: open --> open-fixed
    • assigned_to: André Simon
     
  • Zenju

    Zenju - 2026-11-04

    Awesome! :) 3.6.21 works perfectly!

     
  • Zenju

    Zenju - 2026-11-04

    One (related?) issue "missing indent" before "nextdata":

    Result of 3.6.21:

    #define GetNextData(param) \
        nextdata = (param) |  \
        (1 << 8)
    

    Expected: (This used to work I think in Astyle 3.1)

    #define GetNextData(param) \
        nextdata = (param) |  \
                   (1 << 8)
    
     

    Last edit: Zenju 2026-11-04
  • André Simon

    André Simon - 1 day ago
    • status: open-fixed --> open-accepted
     

Log in to post a comment.