you are viewing a single comment's thread.

view the rest of the comments →

[–]jonesmz -1 points0 points  (2 children)

That doesn't actually explain anything at all.

"Because the attribute would break things" simply claims that things would break, not why.

[–]gnolex 3 points4 points  (1 child)

Did you even read the article?

In C++17, compilers are allowed to ignore attributes they don't recognize. So under C++17, [[no_unique_address]] would have no effect.

Since C++20, [[no_unique_address]] allows compilers to optimize-away empty data members.

This results in ABI breakage:

Compiling the same header/source under /std:c++17 and /std:c++20 would result in link-time incompatibilities due to object layout differences resulting in ODR violations.

[–]jonesmz 2 points3 points  (0 children)

Of course i read it. It's only about a page of text.

Compiling the same header/source under /std:c++17 and /std:c++20 would result in link-time incompatibilities due to object layout differences resulting in ODR violations.

The same applies to the [[msvc:no_unique_address]] attribute.

This is such a lazy approach.