Error building julia; bug in latest gcc (9.0.0 experimental), or in Julia's gc code?

Hi,
I’ve been getting the following error when trying to build Julia (v0.6.2 / v0.6.3 / master):

In file included from /home/chris/Documents/prog/julia-reg/src/codegen.cpp:105:
/home/chris/Documents/prog/julia-reg/src/cgutils.cpp: In function ‘void _hook_call(jl_value_t*, std::array<_jl_value_t*, N>)’:
/home/chris/Documents/prog/julia-reg/src/julia.h:696:55: error: lvalue required as unary ‘&’ operand
   jl_pgcstack = (jl_gcframe_t*)&(((void**)rts_var)[-2])
                                                       ^
/home/chris/Documents/prog/julia-reg/src/cgutils.cpp:112:5: note: in expansion of macro ‘JL_GC_PUSHARGS’
     JL_GC_PUSHARGS(argv, N+1);

While using:

$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/9.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --program-suffix=-trunk : (reconfigured) ../gcc-trunk/configure --program-suffix=-trunk --enable-languages=c,c++,fortran,lto,objc --no-create --no-recursion
Thread model: posix
gcc version 9.0.0 20180524 (experimental) (GCC)

The code that produces the error has been the same for ages, and compiles fine under gcc 8.1.0 (the latest release) and earlier.
I’d have to do a lot of digging to find out whether it’s a bug in gcc 9, or that it uncovered an old bug here.

Obviously I can checkout gcc 8.1 again if I just wanted to have Julia, but thought I should post here, in case someone from Julia wants to know, or if I should file a gcc bug report.

For reference, here’s the full output:

$ make CC=gcc-trunk CXX=g++-trunk FC=gfortran-trunk -j32
    CC src/codegen.o
In file included from /home/chris/Documents/prog/julia/usr/include/llvm/Target/TargetSubtargetInfo.h:18,
                 from /home/chris/Documents/prog/julia/src/codegen.cpp:39:
/home/chris/Documents/prog/julia/usr/include/llvm/CodeGen/SchedulerRegistry.h: In constructor ‘llvm::RegisterScheduler::RegisterScheduler(const char*, const char*, llvm::RegisterScheduler::FunctionPassCtor)’:
/home/chris/Documents/prog/julia/usr/include/llvm/CodeGen/SchedulerRegistry.h:42:52: warning: cast between incompatible function types from ‘llvm::RegisterScheduler::FunctionPassCtor’ {aka ‘llvm::ScheduleDAGSDNodes* (*)(llvm::SelectionDAGISel*, llvm::CodeGenOpt::Level)’} to ‘llvm::MachinePassCtor’ {aka ‘void* (*)()’} [-Wcast-function-type]
   : MachinePassRegistryNode(N, D, (MachinePassCtor)C)
                                                    ^
In file included from /home/chris/Documents/prog/julia/src/codegen.cpp:120:
/home/chris/Documents/prog/julia/src/cgutils.cpp: In function ‘void _hook_call(jl_value_t*, std::array<_jl_value_t*, N>)’:
/home/chris/Documents/prog/julia/src/julia.h:627:55: error: lvalue required as unary ‘&’ operand
   jl_pgcstack = (jl_gcframe_t*)&(((void**)rts_var)[-2])
                                                       ^
/home/chris/Documents/prog/julia/src/cgutils.cpp:50:5: note: in expansion of macro ‘JL_GC_PUSHARGS’
     JL_GC_PUSHARGS(argv, N+1);
     ^~~~~~~~~~~~~~
In file included from /home/chris/Documents/prog/julia/usr/include/llvm/Support/Allocator.h:24,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/ADT/StringMap.h:18,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/Support/Host.h:17,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/ADT/Hashing.h:49,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/ADT/ArrayRef.h:13,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/Support/CommandLine.h:23,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/CodeGen/MachinePassRegistry.h:22,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/CodeGen/SchedulerRegistry.h:18,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/Target/TargetSubtargetInfo.h:18,
                 from /home/chris/Documents/prog/julia/src/codegen.cpp:39:
/home/chris/Documents/prog/julia/usr/include/llvm/ADT/SmallVector.h: In instantiation of ‘void llvm::SmallVectorTemplateBase<T, true>::push_back(const T&) [with T = std::pair<std::pair<llvm::MCSection*, const llvm::MCExpr*>, std::pair<llvm::MCSection*, const llvm::MCExpr*> >]’:
/home/chris/Documents/prog/julia/usr/include/llvm/MC/MCStreamer.h:321:66:   required from here
/home/chris/Documents/prog/julia/usr/include/llvm/ADT/SmallVector.h:305:11: warning: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘struct std::pair<std::pair<llvm::MCSection*, const llvm::MCExpr*>, std::pair<llvm::MCSection*, const llvm::MCExpr*> >’ with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Wclass-memaccess]
     memcpy(this->end(), &Elt, sizeof(T));
     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/local/include/c++/9.0.0/bits/stl_algobase.h:64,
                 from /usr/local/include/c++/9.0.0/bits/char_traits.h:39,
                 from /usr/local/include/c++/9.0.0/string:40,
                 from /home/chris/Documents/prog/julia/src/codegen.cpp:26:
/usr/local/include/c++/9.0.0/bits/stl_pair.h:198:12: note: ‘struct std::pair<std::pair<llvm::MCSection*, const llvm::MCExpr*>, std::pair<llvm::MCSection*, const llvm::MCExpr*> >’ declared here
     struct pair
            ^~~~
In file included from /home/chris/Documents/prog/julia/usr/include/llvm/Support/Allocator.h:24,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/ADT/StringMap.h:18,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/Support/Host.h:17,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/ADT/Hashing.h:49,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/ADT/ArrayRef.h:13,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/Support/CommandLine.h:23,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/CodeGen/MachinePassRegistry.h:22,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/CodeGen/SchedulerRegistry.h:18,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/Target/TargetSubtargetInfo.h:18,
                 from /home/chris/Documents/prog/julia/src/codegen.cpp:39:
/home/chris/Documents/prog/julia/usr/include/llvm/ADT/SmallVector.h: In instantiation of ‘void llvm::SmallVectorTemplateBase<T, true>::push_back(const T&) [with T = std::pair<_jl_value_t**, llvm::GlobalVariable*>]’:
/home/chris/Documents/prog/julia/src/codegen.cpp:6331:53:   required from here
/home/chris/Documents/prog/julia/usr/include/llvm/ADT/SmallVector.h:305:11: warning: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘struct std::pair<_jl_value_t**, llvm::GlobalVariable*>’ with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Wclass-memaccess]
     memcpy(this->end(), &Elt, sizeof(T));
     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/local/include/c++/9.0.0/bits/stl_algobase.h:64,
                 from /usr/local/include/c++/9.0.0/bits/char_traits.h:39,
                 from /usr/local/include/c++/9.0.0/string:40,
                 from /home/chris/Documents/prog/julia/src/codegen.cpp:26:
/usr/local/include/c++/9.0.0/bits/stl_pair.h:198:12: note: ‘struct std::pair<_jl_value_t**, llvm::GlobalVariable*>’ declared here
     struct pair
            ^~~~
In file included from /home/chris/Documents/prog/julia/usr/include/llvm/Support/Allocator.h:24,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/ADT/StringMap.h:18,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/Support/Host.h:17,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/ADT/Hashing.h:49,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/ADT/ArrayRef.h:13,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/Support/CommandLine.h:23,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/CodeGen/MachinePassRegistry.h:22,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/CodeGen/SchedulerRegistry.h:18,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/Target/TargetSubtargetInfo.h:18,
                 from /home/chris/Documents/prog/julia/src/codegen.cpp:39:
/home/chris/Documents/prog/julia/usr/include/llvm/ADT/SmallVector.h: In instantiation of ‘void llvm::SmallVectorTemplateBase<T, true>::push_back(const T&) [with T = std::pair<void*, long unsigned int>]’:
/home/chris/Documents/prog/julia/usr/include/llvm/Support/Allocator.h:238:33:   required from ‘void* llvm::BumpPtrAllocatorImpl<AllocatorT, SlabSize, SizeThreshold>::Allocate(size_t, size_t) [with AllocatorT = llvm::MallocAllocator; long unsigned int SlabSize = 4096; long unsigned int SizeThreshold = 4096; size_t = long unsigned int]’
/home/chris/Documents/prog/julia/usr/include/llvm/MC/MCContext.h:575:44:   required from here
/home/chris/Documents/prog/julia/usr/include/llvm/ADT/SmallVector.h:305:11: warning: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘struct std::pair<void*, long unsigned int>’ with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Wclass-memaccess]
     memcpy(this->end(), &Elt, sizeof(T));
     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/local/include/c++/9.0.0/bits/stl_algobase.h:64,
                 from /usr/local/include/c++/9.0.0/bits/char_traits.h:39,
                 from /usr/local/include/c++/9.0.0/string:40,
                 from /home/chris/Documents/prog/julia/src/codegen.cpp:26:
/usr/local/include/c++/9.0.0/bits/stl_pair.h:198:12: note: ‘struct std::pair<void*, long unsigned int>’ declared here
     struct pair
            ^~~~
In file included from /home/chris/Documents/prog/julia/usr/include/llvm/Support/Allocator.h:24,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/ADT/StringMap.h:18,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/Support/Host.h:17,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/ADT/Hashing.h:49,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/ADT/ArrayRef.h:13,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/Support/CommandLine.h:23,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/CodeGen/MachinePassRegistry.h:22,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/CodeGen/SchedulerRegistry.h:18,
                 from /home/chris/Documents/prog/julia/usr/include/llvm/Target/TargetSubtargetInfo.h:18,
                 from /home/chris/Documents/prog/julia/src/codegen.cpp:39:
/home/chris/Documents/prog/julia/usr/include/llvm/ADT/SmallVector.h: In instantiation of ‘static void llvm::SmallVectorTemplateBase<T, true>::uninitialized_copy(T1*, T1*, T2*, typename std::enable_if<std::is_same<typename std::remove_const<T1>::type, T2>::value>::type*) [with T1 = const std::pair<const llvm::MCSymbol*, const llvm::MCSymbol*>; T2 = std::pair<const llvm::MCSymbol*, const llvm::MCSymbol*>; T = std::pair<const llvm::MCSymbol*, const llvm::MCSymbol*>; typename std::enable_if<std::is_same<typename std::remove_const<T1>::type, T2>::value>::type = void]’:
/home/chris/Documents/prog/julia/usr/include/llvm/ADT/SmallVector.h:396:5:   required from ‘void llvm::SmallVectorImpl<T>::append(in_iter, in_iter) [with in_iter = const std::pair<const llvm::MCSymbol*, const llvm::MCSymbol*>*; T = std::pair<const llvm::MCSymbol*, const llvm::MCSymbol*>]’
/home/chris/Documents/prog/julia/usr/include/llvm/ADT/SmallVector.h:855:5:   required from ‘llvm::SmallVector<T, N>::SmallVector(ItTy, ItTy) [with ItTy = const std::pair<const llvm::MCSymbol*, const llvm::MCSymbol*>*; T = std::pair<const llvm::MCSymbol*, const llvm::MCSymbol*>; unsigned int N = 2]’
/home/chris/Documents/prog/julia/usr/include/llvm/MC/MCFragment.h:547:42:   required from here
/home/chris/Documents/prog/julia/usr/include/llvm/ADT/SmallVector.h:293:13: warning: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘struct std::pair<const llvm::MCSymbol*, const llvm::MCSymbol*>’ with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Wclass-memaccess]
       memcpy(Dest, I, (E - I) * sizeof(T));
       ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/local/include/c++/9.0.0/bits/stl_algobase.h:64,
                 from /usr/local/include/c++/9.0.0/bits/char_traits.h:39,
                 from /usr/local/include/c++/9.0.0/string:40,
                 from /home/chris/Documents/prog/julia/src/codegen.cpp:26:
/usr/local/include/c++/9.0.0/bits/stl_pair.h:198:12: note: ‘struct std::pair<const llvm::MCSymbol*, const llvm::MCSymbol*>’ declared here
     struct pair
            ^~~~
Makefile:144: recipe for target 'codegen.o' failed
make[1]: *** [codegen.o] Error 1
Makefile:94: recipe for target 'julia-src-release' failed
make: *** [julia-src-release] Error 2

Try removing one of the extra pairs of parentheses after the &. I don’t have the C standard in front of me, but I imagine that that might turn an lvalue into an rvalue.

No luck. Removing the outer most parenthesis results in the same error, while removing those around rts_var:

jl_pgcstack = (jl_gcframe_t*)&((void**)rts_var[-2])

results in that error appearing in many places throughout the build:

    CC src/jloptions.o
In file included from /home/chris/Documents/prog/julia/src/jltypes.c:14:
/home/chris/Documents/prog/julia/src/jltypes.c: In function ‘jl_type_union’:
/home/chris/Documents/prog/julia/src/julia.h:627:32: error: lvalue required as unary ‘&’ operand
   jl_pgcstack = (jl_gcframe_t*)&((void**)rts_var[-2])
                                ^
/home/chris/Documents/prog/julia/src/jltypes.c:405:5: note: in expansion of macro ‘JL_GC_PUSHARGS’
     JL_GC_PUSHARGS(temp, nt+1);
     ^~~~~~~~~~~~~~
/home/chris/Documents/prog/julia/src/jltypes.c: In function ‘jl_apply_type2’:
/home/chris/Documents/prog/julia/src/julia.h:627:32: error: lvalue required as unary ‘&’ operand
   jl_pgcstack = (jl_gcframe_t*)&((void**)rts_var[-2])
                                ^
/home/chris/Documents/prog/julia/src/jltypes.c:836:5: note: in expansion of macro ‘JL_GC_PUSHARGS’
     JL_GC_PUSHARGS(args, 2);
     ^~~~~~~~~~~~~~
/home/chris/Documents/prog/julia/src/jltypes.c: In function ‘check_datatype_parameters’:
/home/chris/Documents/prog/julia/src/julia.h:627:32: error: lvalue required as unary ‘&’ operand
   jl_pgcstack = (jl_gcframe_t*)&((void**)rts_var[-2])
                                ^
/home/chris/Documents/prog/julia/src/jltypes.c:953:5: note: in expansion of macro ‘JL_GC_PUSHARGS’
     JL_GC_PUSHARGS(bounds, np*2);
     ^~~~~~~~~~~~~~
In file included from /home/chris/Documents/prog/julia/src/gf.c:14:
/home/chris/Documents/prog/julia/src/gf.c: In function ‘jl_type_infer’:
/home/chris/Documents/prog/julia/src/julia.h:627:32: error: lvalue required as unary ‘&’ operand
   jl_pgcstack = (jl_gcframe_t*)&((void**)rts_var[-2])
                                ^
/home/chris/Documents/prog/julia/src/gf.c:247:5: note: in expansion of macro ‘JL_GC_PUSHARGS’
     JL_GC_PUSHARGS(fargs, 3);
     ^~~~~~~~~~~~~~
/home/chris/Documents/prog/julia/src/jltypes.c: In function ‘inst_tuple_w_’:
/home/chris/Documents/prog/julia/src/julia.h:627:32: error: lvalue required as unary ‘&’ operand
   jl_pgcstack = (jl_gcframe_t*)&((void**)rts_var[-2])
                                ^
/home/chris/Documents/prog/julia/src/jltypes.c:1317:5: note: in expansion of macro ‘JL_GC_PUSHARGS’
     JL_GC_PUSHARGS(iparams, onstack ? ntp : 1);
     ^~~~~~~~~~~~~~
/home/chris/Documents/prog/julia/src/jltypes.c: In function ‘inst_type_w_’:
/home/chris/Documents/prog/julia/src/julia.h:627:32: error: lvalue required as unary ‘&’ operand
   jl_pgcstack = (jl_gcframe_t*)&((void**)rts_var[-2])
                                ^
/home/chris/Documents/prog/julia/src/jltypes.c:1417:5: note: in expansion of macro ‘JL_GC_PUSHARGS’
     JL_GC_PUSHARGS(iparams, ntp);
     ^~~~~~~~~~~~~~
In file included from /home/chris/Documents/prog/julia/src/builtins.c:24:
/home/chris/Documents/prog/julia/src/builtins.c: In function ‘jl_f__apply’:
/home/chris/Documents/prog/julia/src/julia.h:627:32: error: lvalue required as unary ‘&’ operand
   jl_pgcstack = (jl_gcframe_t*)&((void**)rts_var[-2])
                                ^
/home/chris/Documents/prog/julia/src/builtins.c:372:5: note: in expansion of macro ‘JL_GC_PUSHARGS’
     JL_GC_PUSHARGS(newargs, onstack ? n : 1);
     ^~~~~~~~~~~~~~
In file included from /home/chris/Documents/prog/julia/src/jlapi.c:14:
/home/chris/Documents/prog/julia/src/jlapi.c: In function ‘jl_call’:
/home/chris/Documents/prog/julia/src/julia.h:627:32: error: lvalue required as unary ‘&’ operand
   jl_pgcstack = (jl_gcframe_t*)&((void**)rts_var[-2])
                                ^
/home/chris/Documents/prog/julia/src/jlapi.c:140:9: note: in expansion of macro ‘JL_GC_PUSHARGS’
         JL_GC_PUSHARGS(argv, nargs+1);
         ^~~~~~~~~~~~~~
/home/chris/Documents/prog/julia/src/jlapi.c: In function ‘jl_call1’:
/home/chris/Documents/prog/julia/src/julia.h:627:32: error: lvalue required as unary ‘&’ operand
   jl_pgcstack = (jl_gcframe_t*)&((void**)rts_var[-2])
                                ^
/home/chris/Documents/prog/julia/src/jlapi.c:180:9: note: in expansion of macro ‘JL_GC_PUSHARGS’
         JL_GC_PUSHARGS(argv, 2);
         ^~~~~~~~~~~~~~
/home/chris/Documents/prog/julia/src/gf.c: In function ‘arg_type_tuple’:
/home/chris/Documents/prog/julia/src/julia.h:627:32: error: lvalue required as unary ‘&’ operand
   jl_pgcstack = (jl_gcframe_t*)&((void**)rts_var[-2])
                                ^
/home/chris/Documents/prog/julia/src/gf.c:1499:9: note: in expansion of macro ‘JL_GC_PUSHARGS’
         JL_GC_PUSHARGS(types, nargs);
         ^~~~~~~~~~~~~~
/home/chris/Documents/prog/julia/src/jlapi.c: In function ‘jl_call2’:
/home/chris/Documents/prog/julia/src/julia.h:627:32: error: lvalue required as unary ‘&’ operand
   jl_pgcstack = (jl_gcframe_t*)&((void**)rts_var[-2])
                                ^
/home/chris/Documents/prog/julia/src/jlapi.c:200:9: note: in expansion of macro ‘JL_GC_PUSHARGS’
         JL_GC_PUSHARGS(argv, 3);
         ^~~~~~~~~~~~~~
/home/chris/Documents/prog/julia/src/jlapi.c: In function ‘jl_call3’:
/home/chris/Documents/prog/julia/src/julia.h:627:32: error: lvalue required as unary ‘&’ operand
   jl_pgcstack = (jl_gcframe_t*)&((void**)rts_var[-2])
                                ^
/home/chris/Documents/prog/julia/src/jlapi.c:221:9: note: in expansion of macro ‘JL_GC_PUSHARGS’
         JL_GC_PUSHARGS(argv, 4);
         ^~~~~~~~~~~~~~
In file included from /home/chris/Documents/prog/julia/src/precompile.c:11:
/home/chris/Documents/prog/julia/src/precompile.c: In function ‘_compile_all_tvar_union’:
/home/chris/Documents/prog/julia/src/julia.h:627:32: error: lvalue required as unary ‘&’ operand
   jl_pgcstack = (jl_gcframe_t*)&((void**)rts_var[-2])
                                ^
/home/chris/Documents/prog/julia/src/precompile.c:111:5: note: in expansion of macro ‘JL_GC_PUSHARGS’
     JL_GC_PUSHARGS(env, 2 * tvarslen);
     ^~~~~~~~~~~~~~
In file included from /home/chris/Documents/prog/julia/src/interpreter.c:9:
/home/chris/Documents/prog/julia/src/interpreter.c: In function ‘do_call’:
/home/chris/Documents/prog/julia/src/julia.h:627:32: error: lvalue required as unary ‘&’ operand
   jl_pgcstack = (jl_gcframe_t*)&((void**)rts_var[-2])
                                ^
/home/chris/Documents/prog/julia/src/interpreter.c:71:5: note: in expansion of macro ‘JL_GC_PUSHARGS’
     JL_GC_PUSHARGS(argv, nargs);
     ^~~~~~~~~~~~~~
/home/chris/Documents/prog/julia/src/interpreter.c: In function ‘do_invoke’:
/home/chris/Documents/prog/julia/src/julia.h:627:32: error: lvalue required as unary ‘&’ operand
   jl_pgcstack = (jl_gcframe_t*)&((void**)rts_var[-2])
                                ^
/home/chris/Documents/prog/julia/src/interpreter.c:83:5: note: in expansion of macro ‘JL_GC_PUSHARGS’
     JL_GC_PUSHARGS(argv, nargs - 1);
     ^~~~~~~~~~~~~~
/home/chris/Documents/prog/julia/src/sys.c: In function ‘jl_readuntil’:
/home/chris/Documents/prog/julia/src/sys.c:284:17: warning: unused variable ‘truncret’ [-Wunused-variable]
             int truncret = ios_trunc(&dest, n); // it should always be possible to truncate dest
                 ^~~~~~~~
Makefile:140: recipe for target 'jlapi.o' failed
make[1]: *** [jlapi.o] Error 1
make[1]: *** Waiting for unfinished jobs....
/home/chris/Documents/prog/julia/src/interpreter.c: In function ‘jl_interpret_call’:
/home/chris/Documents/prog/julia/src/julia.h:627:32: error: lvalue required as unary ‘&’ operand
   jl_pgcstack = (jl_gcframe_t*)&((void**)rts_var[-2])
                                ^
/home/chris/Documents/prog/julia/src/interpreter.c:659:5: note: in expansion of macro ‘JL_GC_PUSHARGS’
     JL_GC_PUSHARGS(locals, jl_source_nslots(src) + jl_source_nssavalues(src) + 2);
     ^~~~~~~~~~~~~~
/home/chris/Documents/prog/julia/src/interpreter.c: In function ‘jl_interpret_toplevel_thunk’:
/home/chris/Documents/prog/julia/src/julia.h:627:32: error: lvalue required as unary ‘&’ operand
   jl_pgcstack = (jl_gcframe_t*)&((void**)rts_var[-2])
                                ^
/home/chris/Documents/prog/julia/src/interpreter.c:685:5: note: in expansion of macro ‘JL_GC_PUSHARGS’
     JL_GC_PUSHARGS(locals, jl_source_nslots(src) + jl_source_nssavalues(src));
     ^~~~~~~~~~~~~~
Makefile:140: recipe for target 'precompile.o' failed
make[1]: *** [precompile.o] Error 1
Makefile:140: recipe for target 'jltypes.o' failed
make[1]: *** [jltypes.o] Error 1
Makefile:140: recipe for target 'gf.o' failed
make[1]: *** [gf.o] Error 1
Makefile:140: recipe for target 'interpreter.o' failed
make[1]: *** [interpreter.o] Error 1
Makefile:140: recipe for target 'builtins.o' failed
make[1]: *** [builtins.o] Error 1
Makefile:94: recipe for target 'julia-src-release' failed
make: *** [julia-src-release] Error 2

Implying that the line as it currently is:

jl_pgcstack = (jl_gcframe_t*)&(((void**)rts_var)[-2])

is fine in for all those files, but something goes wrong while trying to build codegen.

EDIT:
I did just confirm that it does still build with gcc 8.1.0. I am only having issues with gcc 9.0.0.

Remove the inner most cast

That worked:

#define JL_GC_PUSHARGS(rts_var,n)                               \
  rts_var = ((jl_value_t**)alloca(((n)+2)*sizeof(jl_value_t*)))+2;    \
  ((void**)rts_var)[-2] = (void*)(((size_t)(n))<<1);                  \
  ((void**)rts_var)[-1] = jl_pgcstack;                          \
  memset((void*)rts_var, 0, (n)*sizeof(jl_value_t*));           \
  jl_pgcstack = (jl_gcframe_t*)&((rts_var)[-2])
//  jl_pgcstack = (jl_gcframe_t*)&(((void**)rts_var)[-2])

What does casting to void** do – and what are the consequences of removing it?

If you don’t want to change any requirement on the caller, you can use.

jl_pgcstack = (jl_gcframe_t*)((void**)(rts_var) - 2)

(Or void*** if you want to code to be exactly the same as before…)

That’s not the one I meant. I meant:

jl_pgcstack = (jl_gcframe_t*)&((void**)rts_var)[-2]

Sorry I wasn’t clear – I did try that first, but it resulted in the same error as I had earlier:

/home/chris/Documents/prog/julia-reg/src/julia.h:696:55: error: lvalue required as unary ‘&’ operand
   jl_pgcstack = (jl_gcframe_t*)&((void**)rts_var)[-2]
                                                     ^

So out of curiosity I tried what I showed that post (removing parenthesis around rts_var), and that time got the error in many different places, much earlier.

Yuyichao – I assume it is better not to change requirements? That suggestion also worked without issue:

jl_pgcstack = (jl_gcframe_t*)((void**)(rts_var) - 2)

In that case, that sounds like a gcc bug to me. The C standard is fairly clear that a & and [] need to semantically cancel.

Okay – think I should say something on their mailing list?