Project

General

Profile

Bug #9534

Incorrect printing of Linux BUILD_BUG_ON

Added by Evgeny Novikov 5 months ago. Updated 5 months 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

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

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

Actions

History

#1

Updated by Evgeny Novikov 5 months ago

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

Updated by Evgeny Novikov 5 months ago

#3

Updated by Evgeny Novikov 5 months ago

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

Updated by Evgeny Novikov 5 months ago

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

Updated by Evgeny Novikov 5 months ago

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

Updated by Evgeny Novikov 5 months 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.

#7

Updated by Evgeny Novikov 5 months ago

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

After all this just duplicates #5407.

#8

Updated by Evgeny Novikov 5 months ago

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

Updated by Evgeny Novikov 5 months ago

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

Updated by Evgeny Novikov 5 months ago

Also available in: Atom PDF