https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80243
--- Comment #8 from Jim Michaels <jmichae3 at yahoo dot com> --- you are right, that code does work, my example needed debugging. so if I can return a struct here, why not in my other code, unless gcc is confused somehow? alas, I cannot supply source or .ii files because the library cannot be under the GNU license. here's some fun free example code, and yeah, it works too. #include <iostream> #include <string> #include <initializer_list> #include <vector> typedef struct {std::string s;int i;} Structsb; typedef std::vector<Structsb> VStructsb; VStructsb files={{"abcd",1},{"efgh",2}}; VStructsb& fn(std::string s1, int i1) {//can be with or without &, & faster files.push_back({s1,i1}); return files; } int main() { std::cout<<fn("string",1)[1].s<<files[1].i<<std::endl; return files[0].i; } you don't have to debug my code for me. but the compiler is throwing loads of useless error messages (which I can wade through), but it's not helping me find where things went wrong. I am stuck with no compilers that work. I have waited a long time for something that works. how do I get a working compiler? Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=C:/x86_64-6.2.0-release-win32-sjlj-rt_v5-rev1/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/6.2.0/lto-wrapper.exe Target: x86_64-w64-mingw32 Configured with: ../../../src/gcc-6.2.0/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw620/x86_64-620-win32-sjlj-rt_v5-rev1/mingw64 --enable-shared --enable-static --enable-targets=all --enable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=win32 --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --enable-libstdcxx-filesystem-ts=yes --enable-sjlj-exceptions --disable-isl-version-check --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch-32=i686 --with-arch-64=nocona --with-tune-32=generic --with-tune-64=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw620/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mingw620/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw620/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mingw620/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-win32-sjlj-rev1, Built by MinGW-W64 project' --with-bugurl=http://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -I/c/mingw620/x86_64-620-win32-sjlj-rt_v5-rev1/mingw64/opt/include -I/c/mingw620/prerequisites/x86_64-zlib-static/include -I/c/mingw620/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -I/c/mingw620/x86_64-620-win32-sjlj-rt_v5-rev1/mingw64/opt/include -I/c/mingw620/prerequisites/x86_64-zlib-static/include -I/c/mingw620/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS= LDFLAGS='-pipe -L/c/mingw620/x86_64-620-win32-sjlj-rt_v5-rev1/mingw64/opt/lib -L/c/mingw620/prerequisites/x86_64-zlib-static/lib -L/c/mingw620/prerequisites/x86_64-w64-mingw32-static/lib ' Thread model: win32 gcc version 6.2.0 (x86_64-win32-sjlj-rev1, Built by MinGW-W64 project) COLLECT_GCC_OPTIONS='-static' '-Os' '-save-temps' '-v' '-std=c++11' '-o' 'atoi64.o' '-mtune=core2' '-march=nocona' C:/x86_64-6.2.0-release-win32-sjlj-rt_v5-rev1/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/6.2.0/cc1plus.exe -E -quiet -v -iprefix C:/x86_64-6.2.0-release-win32-sjlj-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/ -U_REENTRANT atoi64.cpp -mtune=core2 -march=nocona -std=c++11 -Os -fpch-preprocess -o atoi64.ii ignoring duplicate directory "C:/x86_64-6.2.0-release-win32-sjlj-rt_v5-rev1/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/6.2.0/include/c++" ignoring duplicate directory "C:/x86_64-6.2.0-release-win32-sjlj-rt_v5-rev1/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/6.2.0/include/c++/x86_64-w64-mingw32" ignoring duplicate directory "C:/x86_64-6.2.0-release-win32-sjlj-rt_v5-rev1/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/6.2.0/include/c++/backward" ignoring duplicate directory "C:/x86_64-6.2.0-release-win32-sjlj-rt_v5-rev1/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/6.2.0/include" ignoring nonexistent directory "C:/mingw620/x86_64-620-win32-sjlj-rt_v5-rev1/mingw64C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/6.2.0/../../../../include" ignoring duplicate directory "C:/x86_64-6.2.0-release-win32-sjlj-rt_v5-rev1/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/6.2.0/include-fixed" ignoring duplicate directory "C:/x86_64-6.2.0-release-win32-sjlj-rt_v5-rev1/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/6.2.0/../../../../x86_64-w64-mingw32/include" ignoring nonexistent directory "C:/mingw620/x86_64-620-win32-sjlj-rt_v5-rev1/mingw64/mingw/include" #include "..." search starts here: #include <...> search starts here: C:/x86_64-6.2.0-release-win32-sjlj-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/include/c++ C:/x86_64-6.2.0-release-win32-sjlj-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/include/c++/x86_64-w64-mingw32 C:/x86_64-6.2.0-release-win32-sjlj-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/include/c++/backward C:/x86_64-6.2.0-release-win32-sjlj-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/include C:/x86_64-6.2.0-release-win32-sjlj-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/include-fixed C:/x86_64-6.2.0-release-win32-sjlj-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/../../../../x86_64-w64-mingw32/include End of search list. COLLECT_GCC_OPTIONS='-static' '-Os' '-save-temps' '-v' '-std=c++11' '-o' 'atoi64.o' '-mtune=core2' '-march=nocona' C:/x86_64-6.2.0-release-win32-sjlj-rt_v5-rev1/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/6.2.0/cc1plus.exe -fpreprocessed atoi64.ii -quiet -dumpbase atoi64.cpp -mtune=core2 -march=nocona -auxbase atoi64 -Os -std=c++11 -version -o atoi64.s GNU C++11 (x86_64-win32-sjlj-rev1, Built by MinGW-W64 project) version 6.2.0 (x86_64-w64-mingw32) compiled by GNU C version 6.2.0, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version 0.15 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU C++11 (x86_64-win32-sjlj-rev1, Built by MinGW-W64 project) version 6.2.0 (x86_64-w64-mingw32) compiled by GNU C version 6.2.0, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version 0.15 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: b3900f5a0b7ba754cd41614b614accf9 whatever happened to friend functions for iostreams and fstreams additional user functionality?