Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to look up GCC's implementation of implementation-defined behavior?

As the C++ standard is very vague on many things, I want to look up the concrete implementations from different compilers. At the moment, I want to know how GCC allocates and aligns bit fields.

In the case of the MS Visual C++ compiler, it is very easy: There is a nice page in the user manual about bit fields which explains all open allocation/alignment questions, and there are even figures and examples.

I just want the same information for GCC, but it seems to be way more complicated. There is a page in the GCC manual which just states "Determined by ABI." Then we have some information about ABI policy and guidelines which contains a link to a document named Itanium C++ ABI on Github. Now, in this document, we can found the following: "the bitfield is allocated as required by the underlying C psABI". And that's the point were I'm stuck. I can find no helpful sites when searching for C psABI.

Can anyone please point me to the site where GCC's implementation of bit fields is described? It can't be that complicated, can't it? Why is GCC's documentation so often so much more complicated then Microsoft's? Am I using the wrong resources?

like image 907
user1494080 Avatar asked Nov 02 '22 05:11

user1494080


1 Answers

That is the difference between GCC (which runs on many, many different machines and operating systems, each with their own convention on how to do some things, the platform's ABI) and MS C, which runs on one platform only (essentially). But that is not all, there are other areas where the standard doesn't dictate what to do, in order to give the compiler writer leeway. If the platform doen't mandate anything either, the compiler writer can choose at will. And the selection might even change seemingly at random from one version of the compiler to the next on the same platform. The compiler should document its choices, but for a beast like GCC covering so many platforms it can be a daunting task to find that.

like image 76
vonbrand Avatar answered Nov 15 '22 04:11

vonbrand