Skip to content

Commit

Permalink
Fix conversion of owning pointer to non-owning in C++98
Browse files Browse the repository at this point in the history
Should fix the build failure of test RepeatUntilCalcArrayType in
`cpp_stl_98`, which looks like this
(https://github.com/kaitai-io/ci_artifacts/blob/7b931f2439b708823fd25a1ee08c7e582b70e261/test_out/cpp_stl_98/build-1.log#L1898-L1901):

```
/tests/compiled/cpp_stl_98/repeat_until_calc_array_type.cpp: In member function 'repeat_until_calc_array_type_t::record_t* repeat_until_calc_array_type_t::first_rec()':
/tests/compiled/cpp_stl_98/repeat_until_calc_array_type.cpp:98:44: error: request for member 'get' in '((repeat_until_calc_array_type_t*)this)->repeat_until_calc_array_type_t::recs_accessor()->std::vector<repeat_until_calc_array_type_t::record_t*>::front()', which is of pointer type 'repeat_until_calc_array_type_t::record_t*' (maybe you meant to use '->' ?)
   98 |     m_first_rec = recs_accessor()->front().get();
      |                                            ^~~
```
  • Loading branch information
generalmimon committed Oct 16, 2023
1 parent 72a1384 commit a4f7c66
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,17 @@ class CppCompiler(
case ct: ComplexDataType => ct.isOwningInExpr
case _ => false
}
handleAssignmentSimple(instName, if (isOwningInExpr) s"$valExpr.get()" else valExpr)
val valExprConverted = if (isOwningInExpr) {
config.cppConfig.pointers match {
case RawPointers =>
valExpr
case UniqueAndRawPointers =>
s"$valExpr.get()"
}
} else {
valExpr
}
handleAssignmentSimple(instName, valExprConverted)
}

override def enumDeclaration(curClass: List[String], enumName: String, enumColl: Seq[(Long, EnumValueSpec)]): Unit = {
Expand Down

0 comments on commit a4f7c66

Please sign in to comment.