Frama-C Bug Tracking System - Frama-C
View Issue Details
0000823Frama-CKernelpublic2011-05-12 14:292014-02-12 16:59
Reporterpascal 
Assigned Tomonate 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product VersionFrama-C GIT, precise the release id 
Target VersionFixed in VersionFrama-C Nitrogen-20111001 
Summary0000823: r13417 unsigned bit-fields of width 32 should be promoted to unsigned int (csmith)
Description#include <stdio.h>

struct S { unsigned f:32; } x = { 28349};

unsigned short us = 0xDC23L;

main(){
  int r = (x.f ^ ((short)-87)) >= us;
  printf("%d\n", r);
  return r;
}

gcc w.c && ./a.out
1

But:

~/ppc/bin/toplevel.opt -print w.c | grep -v preprocessing > w2.c && gcc w2.c && ./a.out
0

The front-end is correct in typing unsigned bit-fields as int most of the time, but there should be an exception for unsigned bit-fields of size 32. See http://stackoverflow.com/q/5977456/139746
TagsNo tags attached.
Attached Files

Notes
(0001877)
pascal   
2011-05-12 18:56   
You have forgotten "unsigned" before "bitfields which have a size equal to the size of int" in your commit message.

Unfortunately, you have also forgotten to handle signed 32-bit bitfields in your patch.

Try the following :

Manzana:~ pascal$ ~/ppc/bin/toplevel.byte -val t.c
...
[value] Values for function main:
          r ? {1}
Manzana:~ pascal$ gcc t.c
Manzana:~ pascal$ ./a.out
0
Manzana:~ pascal$ clang t.c
t.c:7:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
main(){
^
1 warning generated.
Manzana:~ pascal$ ./a.out
0
Manzana:~ pascal$ cat t.c
#include <stdio.h>

struct S { signed f:32; } x = { 28349};

unsigned short us = 0xDC23L;

main(){
  int r = (x.f ^ ((short)-87)) >= us;
  printf("%d\n", r);
  return r;
}

(0004791)
monate   
2014-02-12 16:59   
Fix committed to stable/neon branch.

Issue History
2011-05-12 14:29pascalNew Issue
2011-05-12 14:30pascalStatusnew => assigned
2011-05-12 14:30pascalAssigned To => monate
2011-05-12 15:31svn
2011-05-12 15:31svnStatusassigned => resolved
2011-05-12 15:31svnResolutionopen => fixed
2011-05-12 18:56pascalNote Added: 0001877
2011-05-12 18:56pascalStatusresolved => feedback
2011-05-12 18:56pascalResolutionfixed => reopened
2011-05-12 18:56pascalNote Edited: 0001877
2011-05-12 18:57pascalStatusfeedback => confirmed
2011-05-13 15:23svn
2011-05-13 16:14monateStatusconfirmed => resolved
2011-05-13 16:14monateResolutionreopened => fixed
2011-10-10 14:13signolesFixed in Version => Frama-C Nitrogen-20111001
2011-10-10 14:14signolesStatusresolved => closed
2013-12-19 01:12svnSource_changeset_attached => framac master 5ac9203a
2013-12-19 01:12svnSource_changeset_attached => framac master 8b0d56b2
2014-02-12 16:54monateSource_changeset_attached => framac stable/neon 5ac9203a
2014-02-12 16:54monateSource_changeset_attached => framac stable/neon 8b0d56b2
2014-02-12 16:59monateNote Added: 0004791
2014-02-12 16:59monateStatusclosed => resolved