﻿id	summary	reporter	owner	description	type	status	priority	component	version	resolution	keywords	cc
147	Can't initialize const member of struct	mlbrooks		"Declare struct thingy with field foo.  In the ""broken"" version, foo is const.  Declare a constructor for thingy that initializes foo from constant 5.  In the ""broken"" version, CFA-cc passes bad C code to GCC; this code tries to take address of address.

cat scratch.cfa
{{{
struct thingy {
  #if broken
  const
  #endif
    size_t foo; 
};
void ?{}(thingy &this) with(this) { 
  foo{ 5 }; 
}
}}}

driver/cfa scratch.cfa -Dbroken
error: lvalue required as unary ‘&’ operand

driver/cfa scratch.cfa
(works)

driver/cfa scratch.cfa -Dbroken -CFA
{{{
((void)(((void)(_tmp_ctor_expr0=(*((unsigned long int **)(&(&(*_X4thisS6thingy_1)._X3fooKm_1)))
                                )
               )
        )
       ,(((void)((*_tmp_ctor_expr0)=((unsigned long int )5)) /* ?{} */)
        ,_tmp_ctor_expr0
        )
       )
);
}}}

driver/cfa scratch.cfa -CFA
{{{
((void)(((void)(_tmp_ctor_expr0=(                           &(*_X4thisS6thingy_1)._X3foom_1
                                )
               )
        )
       ,(((void)((*_tmp_ctor_expr0)=((unsigned long int )5)) /* ?{} */)
        ,_tmp_ctor_expr0
        )
       )
);
}}}
"	defect	new	minor	cfa-cc	1.0			
