This case is similar to #501, but shows that AStyle 3.1 using --align-pointer=type, formats array new inconsistently. The formatting depends on the type.
./astyle --options=none --align-pointer=type < test.cpp
class Foo
{
public:
Foo();
private:
int** i_;
float** f_;
};
Foo::Foo()
: i_(new int*[100])
, f_(new float*[100])
{
i_ = new int*[100];
f_ = new float*[100];
}
The constructor definition ends up as:
Foo::Foo()
: i_(new int* [100])
, f_(new float*[100])
{
i_ = new int* [100];
f_ = new float*[100];
}
As we see, there is unwanted space after the int pointer, but not after the float pointer. I have tried a few other types, and it seems as if only int pointer is formatted incorrectly. This is the opposite of the observation reported in #501.
Disclaimer: I do not write code like this in real life!
In my opinion it's exactly vice versa, the blank after int * is fine whereas there is one missing after float *.
My patch for #501 will also fix this one.
If you don't like any spaces being added before or after the asterisk you shouldn't use option --align-pointer at all, should you?
Last edit: Foo Bar 2019-03-10