Menu

#592 astyle 3.6.8 (git 2025-03-17): unexpected linebreak for inherited class

closed-fixed
None
2025-03-26
2025-03-17
Zenju
No

AStyle built from git 2025-03-17 unexpectedly converts this: (full repro when inside .cpp file)

class CControlSocket
{
    std::vector<std::unique_ptr<int>> operations_;
};

class CRealControlSocket : public CControlSocket
{
};

into this

class CControlSocket
{
    std::vector<std::unique_ptr<int>> operations_;
};

class CRealControlSocket :
    public CControlSocket
{
};

Note the unexpected line break before the "public CControlSocket"

Astyle config used:

--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

Something similar happens with the following example:

struct ObjectCache
{
    std::vector<std::shared_ptr<int>> cache;
};

class CToken final
{
protected:
    enum flags : unsigned char
    {
        numeric_left = 0x01,
    };
};

Astyle adds an unwanted newline before the "unsigned char":

struct ObjectCache
{
    std::vector<std::shared_ptr<int>> cache;
};

class CToken final
{
protected:
    enum flags :
        unsigned char
    {
        numeric_left = 0x01,
    };
};

Discussion

  • Zenju

    Zenju - 2025-03-21

    The ticked can be closed! Apparently the latest changes to
    https://sourceforge.net/p/astyle/bugs/585/
    fixed this one as well! Thanks!

     
  • André Simon

    André Simon - 2025-03-26
    • status: open --> closed-fixed
    • assigned_to: André Simon
     

Log in to post a comment.

MongoDB Logo MongoDB
Gen AI apps are built with MongoDB Atlas
Atlas offers built-in vector search and global availability across 125+ regions. Start building AI apps faster, all in one place.