Bug #9534
closed
Incorrect printing of Linux BUILD_BUG_ON
Added by Evgeny Novikov over 5 years ago.
Updated over 5 years ago.
Description
At the moment C back-end prints:
void __kfree_rcu(struct rcu_head *head, unsigned long offset)
{
...
((void)sizeof(char[1 - 2*!!(!__builtin_constant_p(offset))]));
...
}
as:
void __kfree_rcu(struct rcu_head *head, long unsigned int offset)
{
...
__builtin_constant_p ( offset ) == 0 ? -1 : 1, ( void ) ( long unsigned int ) ( __builtin_constant_p ( offset ) == 0 ? -1 : 1 );
...
}
This is definitely wrong.
- Blocks deleted (Bug #6629: Used CIL is outdated)
- Related to Bug #9546: Frama-C (CIL) for GCC does not behave like GCC when casting ternary operators added
- Related to Bug #5407: Duplicated labels are generated added
Indeed, the situation is not so bad, since there are no bugs in produced code. There is a bug in Frama-C (CIL) that can't parse it (#9536).
GCC calculates sizeofs internally, so, there are always some values and there are no sizeof expressions like in C. In this particular case the compiler could detect that there are no build bugs, i.e. "__builtin_constant_p ( offset ) 0" is always false at a compile time ("__builtin_constant_p(offset)" is always true) and we always have "sizeof(char[1])" that is 1. But there is still original expression calculating array size (it can be removed from the internal representation at all, but this does not happen).
I just dislike the outputted code since it includes "__builtin_constant_p ( offset ) 0 ? -1 : 1" 2 times that is not necessary at all. Perhaps, this causes #9534.
- Status changed from New to Rejected
- Assignee deleted (
Evgeny Novikov)
After all this just duplicates #5407.
- Related to deleted (Bug #5407: Duplicated labels are generated)
- Is duplicate of Bug #5407: Duplicated labels are generated added
Also available in: Atom
PDF