Is a bit field an object?

According to C11, the object:

# C11 § 3: terms, definitions and symbols
object: a runtime storage area whose contents can represent values.

A bit field can represent a value, so it must be an object. But I was told that this is not so.

What is the correct answer?

+4
source share
1 answer

6.2.6.1p2 says: "With the exception of bit fields, objects consist of adjacent sequences of one or more bytes [...]," so it seems clear that bit fields are objects. Similarly, 6.2.6.1p4 refers to "objects without a bit field."

3.5p1 defines a bit as a data storage unit; a bit field is a bit area, therefore it should be a data storage area. The standard makes a distinction between objects and memory cells (a memory cell is “either an object of a scalar type, or the maximum sequence of neighboring bit fields having a nonzero width”; 3.14p1), therefore, the object should not have a separate memory cell.

+7
source

Source: https://habr.com/ru/post/1440833/


All Articles