Frama-C Bug Tracking System - Frama-C
View Issue Details
0000810Frama-CKernelpublic2011-05-02 09:472014-02-12 16:59
Reporterpascal 
Assigned Tomonate 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product VersionFrama-C Carbon-20110201 
Target VersionFixed in VersionFrama-C Nitrogen-20111001 
Summary0000810: pretty-printed program rejected by GCC. Affects -print, slicing, scf (csmith)
Description$ cat const_field_return_struct.c
struct S {
  const int f0;
  int f1; } T, U;

struct S f(int c)
{
  if (c) return T;
  return U;
}
$ frama-c -quiet -print const_field_return_struct.c > t.c
$ cat t.c
/* Generated by Frama-C */
struct S {
   int const f0 ;
   int f1 ;
};
struct S T ;
struct S U ;
struct S f(int c )
{
  struct S __retres ;
  if (c) { __retres = T; goto return_label; }
  __retres = U;
  return_label: /* internal */
  return (__retres);
}
$ gcc t.ct.c: In function 'f':
t.c:11: error: assignment of read-only variable '__retres'
t.c:12: error: assignment of read-only variable '__retres'
TagsNo tags attached.
Attached Files

Notes
(0001837)
pascal   
2011-05-02 10:45   
Interesting remark from Great Leader:


~/ppc $ cat t.c
struct S {
  const int f0;
  int f1; } T, U;

struct S f(int c)
{
  struct S V = { 12, 45 };
  return U;
}
~/ppc $ bin/toplevel.opt -print t.c
[kernel] preprocessing with "gcc -C -E -I. t.c"
/* Generated by Frama-C */
struct S {
   int f0 ;
   int f1 ;
};
struct S T;
struct S U;
struct S f(int c)
{
  struct S V;
  V.f0 = 12;
  V.f1 = 45;
  return (U);
}

So the const-removal-when-necessary code is already there, it is enough to make sure the criterion is widened to include the example provided.

Issue History
2011-05-02 09:47pascalNew Issue
2011-05-02 09:47pascalSummarypretty-printed program rejected by GCC. Affects -print, slicing, scf => pretty-printed program rejected by GCC. Affects -print, slicing, scf (csmith)
2011-05-02 10:45pascalNote Added: 0001837
2011-05-02 10:46pascalAssigned To => monate
2011-05-02 10:46pascalStatusnew => assigned
2011-05-02 16:56svn
2011-05-02 16:56svnStatusassigned => resolved
2011-05-02 16:56svnResolutionopen => 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 e0854297
2014-02-12 16:54monateSource_changeset_attached => framac stable/neon e0854297
2014-02-12 16:59monateStatusclosed => resolved