text: Bugzilla – Bug 148
  [llvmg++] Front-end attempts to return structure by value
  Last modified: 2003-11-25 02:48:05
  You need to
  before you can comment on or make changes to this bug..
  Note that this occurs when gccld's optimizations are enabled or disabled (i.e.
  it's not an optimizer problem).
  This is actually a bug in the g++ front end.
  The front end is creating a function that returns an aggregate type (as opposed
  to moving the aggregate type into the first parameter). This causes there to be
  two different typed functions with the same name. Hence, the JIT goes looking
  for the version returning the aggregate type, can't find it, and fails.
  Now, the trick is: Can I reduce it to a usable test case?
  Created an attachment (id=30) [details]
  Reproduces the problem.
  This reproduces the problem when gccas has assertions that check for functions
  that return aggregate types.
  Thanks for reducing this testcase John!
  -Chris
  Note that, with the new assertion in the parser, this problem is blocking
  building libstdc++. :(
  -Chris
  Testcase reduced to:
  #include <vector>
  std::vector<int> my_method ();
  int main (){
  my_method ();
  return 0;
  }
  ... next step, get rid of #include.
  Fixed.
  Testcase here: 2003-11-25-ReturningOpaqueByValue.cpp
  The patch:
  $ diff -u llvm-types.c~ llvm-types.c
  --- llvm-types.c~ 2003-11-19 18:59:34.000000000 -0600
  +++ llvm-types.c 2003-11-25 02:41:55.000000000 -0600
  @@ -874,7 +874,7 @@
  * returning void and taking struct argument as it's first
  * parameter.
  */
  - if (RetType->ID == StructTyID) {
  + if (RetType->ID == StructTyID || RetType->ID == OpaqueTyID) {
  FirstArgTy = llvm_type_get_pointer(RetType);
  NumArgs++;
  RetType = VoidTy;