The code below compiles correctly on clang 3.8.1-1 in ArchLinux.
Is this a clang error?
gcc enter the correct warning / error.
template <class T> struct BugReproducer{ using size_type = typename T::size_type; int bug1(size_type count); int bug2(size_type count) const; static int bug3(size_type count); }; template <class T> int BugReproducer<T>::bug1(size_type const count){
This is how I compile:
[nmmm@zenbook HM3]$ clang x.cc -std=c++11 -lstdc++ -Wall -Wpedantic -Wconversion
clang and c++14 are the same result.
[nmmm@zenbook HM3]$ clang x.cc -std=c++14 -lstdc++ -Wall -Wpedantic -Wconversion
Here is the gcc output:
[nmmm@zenbook HM3]$ gcc x.cc -std=c++11 -lstdc++ -Wall -Wpedantic -Wconversion x.cc: In instantiation of 'int BugReproducer<T>::bug1(BugReproducer<T>::size_type) [with T = DummyVector; BugReproducer<T>::size_type = int]': x.cc:46:28: required from here x.cc:13:8: error: assignment of read-only parameter 'count' count = 5; ~~~~~~^~~ x.cc: In instantiation of 'int BugReproducer<T>::bug2(BugReproducer<T>::size_type) const [with T = DummyVector; BugReproducer<T>::size_type = int]': x.cc:47:28: required from here x.cc:22:8: error: assignment of read-only parameter 'count' count = 5; ~~~~~~^~~ x.cc: In instantiation of 'static int BugReproducer<T>::bug3(BugReproducer<T>::size_type) [with T = DummyVector; BugReproducer<T>::size_type = int]': x.cc:48:20: required from here x.cc:29:8: error: assignment of read-only parameter 'count' count = 5; ~~~~~~^~~
c ++ c ++ 11 clang c ++ 14
Nick
source share