[Bug c++/69836] New: compilation error with constexpr in template types with redeclared methods

ogoffart at kde dot org gcc-bugzilla@gcc.gnu.org
Tue Feb 16 12:57:00 GMT 2016


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

            Bug ID: 69836
           Summary: compilation error with constexpr in template types
                    with redeclared methods
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ogoffart at kde dot org
  Target Milestone: ---

Created attachment 37701
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37701&action=edit
testcase

The attached code [live: http://melpon.org/wandbox/permlink/wUtHZsr0ZAuiMtK1 ]

Produce a compilation error with GCC while it is accepted by clang.

file.cc:20:57: error: could not convert
'increment<2>((state((number<N>::prev<3>(), number<2>()), w_this), S<2>()))'
from 'S<3>' to 'S<2>'
         RETURN(increment(state(w_counter.prev(), w_this)))
                                                         ^
file.cc:11:43: note: in definition of macro 'RETURN'
 #define RETURN(R) -> decltype(R) { return R; }
                                           ^

Since decltype and the return value are both the same, this should not be a
problem.  It seems that gcc misunderstand the type of w_counter. 
Also in the error message there is "(number<N>::prev<3>(), number<2>())" why is
there a commas there,  and where does this <3> comes from?

When the class (TemplateObject) is not a template, then the compilaiton passes


More information about the Gcc-bugs mailing list