[cfe-dev] Issue 11851

Andrew Sutton asutton.list at gmail.com
Wed Mar 21 10:27:49 PDT 2012


> I was going to try to fix this problem, but I'm not sure where to
> start. What's the right way to ensure that the definition of an
> instantiated template is available in this context i.e., not deferred?

This solves the problem, but causes a couple regressions.

So, it seems that the problem is that constexpr function template
calls in the signatures of function templates cannot be evaluated
because their uses occur in dependent contexts (apparently
instantiating a function template signature as part of overload
resolution occurs within the context of the function template being
instantiated?). The result is that body of the constexpr function
template isn't instantiated in time to be evaluated, hence the
substitution failures.

This patch just ensures that definitions are emitted for those calls.
I tested against the examples given in the bug report, and they seemed
to compile just fine. I also ran the patch against some of my own
examples, and they work well. I neglected to include those in the
patch though.

Unfortunately the patch causes definitions to be emitted for some
functions that aren't actually used, so I didn't quite get it right.
Is there a deeper problem, or do the criteria for generating
definitions just need to be adjusted?

Errors from the test suite are:

SemaCXX/undefined-internal.cpp
error: 'warning' diagnostics expected but not seen:
  Line 9: not needed and will not be emitted
1 error generated.


SemaCXX/warn-unused-filescoped.cpp
error: 'warning' diagnostics seen but not expected:
  Line 177: function 'OverloadUse::<anonymous namespace>::f' has
internal linkage but is not defined
error: 'note' diagnostics expected but not seen:
  Line 181: used here
error: 'note' diagnostics seen but not expected:
  Line 182: used here
  Line 182: used here
4 errors generated.


SemaCXX/warn-unused-filescoped.cpp
error: 'warning' diagnostics expected but not seen:
  Line 83: not needed and will not be emitted
1 error generated.

Andrew
-------------- next part --------------
A non-text attachment was scrubbed...
Name: constexpr-patch
Type: application/octet-stream
Size: 1040 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120321/5d58a78d/attachment.obj>


More information about the cfe-dev mailing list