Opened 5 years ago
#147 new defect
Can't initialize const member of struct
Reported by: | mlbrooks | Owned by: | |
---|---|---|---|
Priority: | minor | Component: | cfa-cc |
Version: | 1.0 | Keywords: | |
Cc: |
Description
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 ) ) );
Note: See
TracTickets for help on using
tickets.