https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81314

            Bug ID: 81314
           Summary: In function `star1(int, std::vector<double,
                    std::allocator<double> >&) [clone ._omp_cpyfn.1]':
                    $(PWD)/stencil-vector-taskloop-gccbug2.cc:4: undefined
                    reference to `std::vector<double,
                    std::allocator<double> >::vector(std::vector<double,
                    std::allocator<dou
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jeff.science at gmail dot com
  Target Milestone: ---

The code included below fails to link with GCC 7.1.0 and git HEAD from
20170627.  It compiles fine, compiles and links fine without OpenMP, and
compiles and links fine with OpenMP using Clang 4.0 and Intel 18.

I did not see this error in the original (i.e. not distilled) source with
omp-parallel-for, so I believe this error is specific to omp-taskloop.

# RESULTS

$ g++-8 -std=c++11 -g -O2 -fopenmp stencil-vector-taskloop-gccbug2.cc -o
stencil-vector-taskloop-gccbug2 && echo SUCCESS || echo FAIL
/tmp/ccsqglsZ.o: In function `star1(int, std::vector<double,
std::allocator<double> >&) [clone ._omp_cpyfn.1]':
$(PWD)/stencil-vector-taskloop-gccbug2.cc:4: undefined reference to
`std::vector<double, std::allocator<double> >::vector(std::vector<double,
std::allocator<double> > const&)'
collect2: error: ld returned 1 exit status
FAIL

$ g++-7 -std=c++11 -g -O2 -fopenmp stencil-vector-taskloop-gccbug2.cc -o
stencil-vector-taskloop-gccbug2 && echo SUCCESS || echo FAIL
/tmp/ccuIhlTa.o: In function `star1(int, std::vector<double,
std::allocator<double> >&) [clone ._omp_cpyfn.1]':
$(PWD)/stencil-vector-taskloop-gccbug2.cc:4: undefined reference to
`std::vector<double, std::allocator<double> >::vector(std::vector<double,
std::allocator<double> > const&)'
collect2: error: ld returned 1 exit status
FAIL

## compile-only

$ g++-8 -std=c++11 -g -O2 -fopenmp -c stencil-vector-taskloop-gccbug2.cc -o
stencil-vector-taskloop-gccbug2.o && echo SUCCESS || echo FAIL
SUCCESS

## without OpenMP

$ g++-8 -std=c++11 -g -O2 stencil-vector-taskloop-gccbug2.cc -o
stencil-vector-taskloop-gccbug2 && echo SUCCESS || echo FAIL
SUCCESS

## other compilers

$ /opt/llvm/4.0.0/bin/clang++ -std=c++11 -g -O2 -fopenmp -Wunused
stencil-vector-taskloop-gccbug2.cc -o stencil-vector-taskloop-gccbug2
/opt/llvm/4.0.0/lib/libomp.so && echo SUCCESS || echo FAIL
SUCCESS

$ icpc -std=c++11 -g -O2 -fopenmp stencil-vector-taskloop-gccbug2.cc -o
stencil-vector-taskloop-gccbug2 && echo SUCCESS || echo FAIL
SUCCESS

# SOURCE

$ cat stencil-vector-taskloop-gccbug2.cc
#include <vector>

void star1(const int n, std::vector<double> & out) {
  _Pragma("omp taskloop")
  for (auto i=0; i<(n*n); ++i) out[i] = 1.0;
}

int main()
{
  const int n = 1000;
  std::vector<double> out;
  out.resize(n*n,0.0);
  _Pragma("omp parallel")
  _Pragma("omp master")
  {
    star1(n, out);
    _Pragma("omp taskwait")
  }
  return 0;
}

# GCC VERSION

$ g++-8 -v
Using built-in specs.
COLLECT_GCC=g++-8
COLLECT_LTO_WRAPPER=/opt/gcc/HEAD/bin/../libexec/gcc/x86_64-pc-linux-gnu/8.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /opt/gcc//git/configure --program-suffix=-8 --disable-multilib
--enable-threads=posix --enable-checking=release --with-system-zlib
--enable-__cxa_atexit --enable-languages=c,c++,fortran --with-tune=native
--enable-bootstrap --enable-lto --enable-gold=yes --enable-ld=yes
--prefix=/opt/gcc//HEAD : (reconfigured) /opt/gcc//git/configure
--program-suffix=-8 --disable-multilib --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--enable-languages=c,c++,fortran --with-tune=native --enable-bootstrap
--enable-lto --enable-gold=yes --enable-ld=yes --prefix=/opt/gcc//HEAD
Thread model: posix
gcc version 8.0.0 20170627 (experimental) (GCC)

$ g++-7 -v
Using built-in specs.
COLLECT_GCC=g++-7
COLLECT_LTO_WRAPPER=/opt/gcc/7.1.0/libexec/gcc/x86_64-pc-linux-gnu/7.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/opt/gcc/7.1.0 --program-suffix=-7
--enable-shared --enable-static --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--enable-languages=c,c++,fortran --with-tune=native --enable-bootstrap
--enable-lto --enable-gold=yes --enable-ld=yes --disable-multilib
Thread model: posix
gcc version 7.1.0 (GCC)

Reply via email to