[cfe-dev] possible clang bug?

Alex L via cfe-dev cfe-dev at lists.llvm.org
Mon Jan 9 07:13:08 PST 2017


This looks like a bug for sure, it reproduces on ToT clang for me as well.

On 9 January 2017 at 14:59, Adam Burr via cfe-dev <cfe-dev at lists.llvm.org>
wrote:

> 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:
>
> 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;
>
>
> 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
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170109/5f86d43f/attachment.html>


More information about the cfe-dev mailing list