Project

General

Profile

Actions

Bug #4911

closed

C-backend fails to inline constants

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

Status:
Rejected
Priority:
Normal
Category:
-
Start date:
05/08/2014
Due date:
% Done:

0%

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

Description

For such the code:

static int const * const vvaraddr_vgetcpu_mode = (void *)((-10*1024*1024 - 4096) + (16));
...
static inline unsigned int __getcpu(void)
{
 ...
 if ((*vvaraddr_vgetcpu_mode) == 1) {
   ...
 }
 ...
}

with enabled GCC optimizations (-Os) C-backend generates:
static int const *const vvaraddr_vgetcpu_mode = 18446744073699061776;
...
static inline unsigned int __getcpu(void)
{
  ...
  if (( int ) * 18446744073699061776 == 1)
  {
    ...
  }
  ...
}

which is obviously improper. Proper code is the following:
static int const *const vvaraddr_vgetcpu_mode = 18446744073699061776;
...
static inline unsigned int __getcpu(void)
{
  ...
  if (( int ) * (int *)18446744073699061776 == 1)
  {
    ...
  }
  ...
}

Linux kernel 3.13-rc1 is subjected to the given issue while 3.5 isn't.


Related issues 2 (0 open2 closed)

Is duplicate of C Instrumentation Framework - Bug #1137: C backend fails to get casting and suffix for integer constants having "pointer" typeClosedEvgeny Novikov04/26/2011

Actions
Blocks C Instrumentation Framework - Bug #4401: Fix C back-end warningsClosedEvgeny Novikov07/28/2013

Actions
Actions #1

Updated by Evgeny Novikov about 10 years ago

BTW this issue plays even without "-Os" option since it causes int-to-pointer warnings (#4401).

Actions #2

Updated by Evgeny Novikov about 10 years ago

  • Status changed from Open to Rejected

Rejected as a duplicate of Bug #1137.

Actions

Also available in: Atom PDF