c - Comma inside enum value definition? -


I have the following flag enum definition (coco macros is used):

  Typed FIS notation (Uint64_t, ItemDataType) {... A = (1 & lt; & lt; 16); B = (1 & lt; & lt; 17); C = (1 & lt; ; 18), ... g = (1 <31;), test = (a | b | c, g)};   

should be tested (a | b | c | g) but we created a typo and entered a. B C, g) . What does this sign mean? What is the real value of test ? Is not this a compiler bug?

, , this is legitimate code, it will evaluate the left operand And then will remove the value and evaluate the right operand and this will result.

CMA draft standard section 6.5.17 comma operator paragraph 2 :

The left operand of a comma operator is evaluated as zero expression; After its evaluation there is a sequence point then correct operation is evaluated; As a result, it has a type and value. 97)

It is also worth noting that the comma operator has it.

/ Code> If you use the -verver flag, provide the following warning:

  Warning: Expression is an integer There is no steady expression; Adding it to stabilize is a GNU extension [-Wagnoo-fold-continuous] test = (A | B | C, g) ^ ~~~~~~~~~~~~~~  

GCC I have one error in this case but also a warning if I use the -Wall flag:

  WARNING: The left hand operators of comma expression have no effect [-vide-value] TEST = (A | B, C) * Error: The value of the counter for an 'test' is not an integer constant Is  

Comments