Project

General

Profile

Actions

Bug #9534

closed

Incorrect printing of Linux BUILD_BUG_ON

Added by Evgeny Novikov about 5 years ago. Updated about 5 years ago.

Status:
Rejected
Priority:
Urgent
Assignee:
-
Category:
C back-end
Start date:
03/13/2019
Due date:
% Done:

0%

Estimated time:
Detected in build:
svn
Platform:
Published in build:

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.


Related issues 2 (0 open2 closed)

Related to Deductive Verification Tools for Linux Kernel - Bug #9546: Frama-C (CIL) for GCC does not behave like GCC when casting ternary operatorsClosedMikhail Mandrykin03/15/2019

Actions
Is duplicate of C Instrumentation Framework - Bug #5407: Duplicated labels are generatedClosedEvgeny Novikov11/05/2014

Actions
Actions #1

Updated by Evgeny Novikov about 5 years ago

  • Blocks Bug #6629: Used CIL is outdated added
Actions #2

Updated by Evgeny Novikov about 5 years ago

Actions #3

Updated by Evgeny Novikov about 5 years ago

  • Blocks deleted (Bug #6629: Used CIL is outdated)
Actions #4

Updated by Evgeny Novikov about 5 years ago

  • Related to Bug #9546: Frama-C (CIL) for GCC does not behave like GCC when casting ternary operators added
Actions #5

Updated by Evgeny Novikov about 5 years ago

  • Related to Bug #5407: Duplicated labels are generated added
Actions #6

Updated by Evgeny Novikov about 5 years ago

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.

Actions #7

Updated by Evgeny Novikov about 5 years ago

  • Status changed from New to Rejected
  • Assignee deleted (Evgeny Novikov)

After all this just duplicates #5407.

Actions #8

Updated by Evgeny Novikov about 5 years ago

  • Related to deleted (Bug #5407: Duplicated labels are generated)
Actions #9

Updated by Evgeny Novikov about 5 years ago

  • Is duplicate of Bug #5407: Duplicated labels are generated added
Actions #10

Updated by Evgeny Novikov about 5 years ago

Actions

Also available in: Atom PDF