Opened 7 years ago

Closed 7 years ago

#54548 closed defect (fixed)

clang++-mp-4.0 and clang++-mp-5.0 fail where /usr/bin/clang++ and g++-mp-6 succeed

Reported by: MarcusCalhoun-Lopez (Marcus Calhoun-Lopez) Owned by: jeremyhu@…
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: larryv@…
Port: clang-4.0

Description

In an attempt to fix #51046, I tried to build VIGRA with a compiler from MacPorts.
macports-clang-4.0 and macports-clang-5.0 failed but macports-gcc-6 succeeded.
Below is the smallest test case I could get it down to.
/usr/bin/clang++ and g++-mp-6 compile it without complaint.
clang++-mp-4.0 and clang++-mp-5.0 fail with the error:

test.cxx:35:5: error: no matching function for call to 'gaussianDivergenceMultiArray'
    gaussianDivergenceMultiArray(array, res);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.cxx:40:1: note: in instantiation of function template specialization 'pythonGaussianDivergence<double, 2>' requested here
pythonGaussianDivergence<double,2>(NumpyArray<2, TinyVector<double, 2> > array,
^
test.cxx:13:1: note: candidate template ignored: could not match 'MultiArrayView' against 'NumpyArray'
gaussianDivergenceMultiArray(MultiArrayView<N, TinyVector<T1, N> > const & vectorField,
^
1 error generated.

Since the Apple supplied clang++ works, I am not sure whether this Trac or the clang mailing list is the more appropriate forum for discussion.
Truth be told, I am no expert in template programming, so it is possible that the code should cause an error, in which case, it is VIGRA's problem.
Test case:

template <unsigned N, class T>
class MultiArrayView
{
};

template <class T, int SIZE>
class TinyVector
{
};

template <unsigned N, class T1, class T2>
inline void
gaussianDivergenceMultiArray(MultiArrayView<N, TinyVector<T1, N> > const & vectorField,
                             MultiArrayView<N, T2> divergence)
{
}

template<unsigned N, class T>
struct NumpyArrayTraits
{
    typedef T value_type;
};

template <unsigned N, class T>
class NumpyArray
: public MultiArrayView<N, typename NumpyArrayTraits<N, T>::value_type>
{
};

template <class PixelType, unsigned N>
void
pythonGaussianDivergence(NumpyArray<N, TinyVector<PixelType, N> > array,
                         NumpyArray<N, double > res)
{
    gaussianDivergenceMultiArray(array, res);
}

template
void
pythonGaussianDivergence<double,2>(NumpyArray<2, TinyVector<double, 2> > array,
				   NumpyArray<2, double > res);

Change History (5)

comment:1 Changed 7 years ago by jeremyhu (Jeremy Huddleston Sequoia)

What is reported by /usr/bin/clang --version?

Please file a bug report at https://bugs.llvm.org and provide a reference to it from here.

comment:2 Changed 7 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)

There is now an upstream bug report #33995.
/usr/bin/clang --version gives

Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

comment:3 Changed 7 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)

According to #33995, Clang should indeed reject the code.
I posted a bug report on the Vigra mailing list.

comment:4 Changed 7 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)

Upstream seems to already have committed a fix.

comment:5 Changed 7 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)

Resolution: fixed
Status: newclosed

In fa032984a531c5e787b026d5db358e1dea568505/macports-ports:

vigra: patch template instantiation

Fixes #54548
No revbump since port either builds correctly or not at all

Note: See TracTickets for help on using tickets.