[cfe-dev] possible clang bug?

Adam Burr via cfe-dev cfe-dev at lists.llvm.org
Mon Jan 9 06:59:22 PST 2017


This compiles in clang 3.8 but I believe it should not: 





template< class T = int > 

struct A 

{ 

struct B {}; 




const B* test (const B* b) const; 

}; 




template< class T > 

inline auto A< T >::test (const B* const b) const -> const B* 

{ 

return ++b; 

} 




int main() 

{ 

A<> m; 

const A<>::B* b = 0; 

b = m.test (b); 

} 




Here is the same code in coliru: 

http://coliru.stacked-crooked.com/a/55a3a6e7d28e8a5d 



gcc reports the error I was expecting: 


<blockquote>


main.cpp: In instantiation of 'const A<T>::B* A<T>::test(const A<T>::B*) const [with T = int]': 

main.cpp:19:18: required from here 

main.cpp:12:9: error: increment of read-only parameter 'b' 

return ++b; 
</blockquote>




This is a very non-critical bug ( if it even is a bug) and I do not need a fix but I thought I would point it out because I happened to notice. 


Thanks, 
Adam Burr 
Blue Sky Studios 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170109/a87ecd78/attachment.html>


More information about the cfe-dev mailing list