[LLVMbugs] [Bug 18043] constexpr function pointers aren't considered valid template arguments (violates [temp.arg.nontype])
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Nov 28 03:10:18 PST 2013
http://llvm.org/bugs/show_bug.cgi?id=18043
M.E. O'Neill <oneill+llvmbugs at cs.hmc.edu> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|INVALID |---
--- Comment #2 from M.E. O'Neill <oneill+llvmbugs at cs.hmc.edu> ---
(In reply to comment #1)
> For more background, see:
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1570
>
> The code is ill-formed because 'fooAddr' does not refer to a function or an
> array (it refers to a pointer), and thus you cannot omit the '&'. (More
> generally, the intent was that C++11 did not let you do new things here,
> such as pushing the address through a constexpr variable.)
>From my reading, that DR is about *subobjects*. This is not a subobject, so
the DR does not apply.
Also, note that your interpretation requires programmers to write this:
template <int x, int y, int z>
void foo()
{
}
template <void (*f)()>
void adapter1()
{
f();
}
template <void (*f)()>
void adapter2()
{
f();
}
template <void (*f)()>
void adapter3()
{
f();
}
void snafu()
{
adapter1<foo<1234567,31415,271828>>();
adapter2<foo<1234567,31415,271828>>();
adapter3<foo<1234567,31415,271828>>();
}
rather than store the desired parameterization of foo in a constexpr constant.
Also, it's hard to justify why you're reject the above code, but accept this
code
template <int x, int y, int z>
void foo()
{
}
template <void (*f)()>
void adapter1()
{
f();
}
template <void (*g)()>
void adapter2()
{
adapter1<g>();
}
void snafu()
{
adapter2<foo<1234567,31415,271828>>();
}
as g is also a pointer to a function, not the function itself.
So, at the very least you should be applying the rules you believe in
consistently.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20131128/b4d0756e/attachment.html>
More information about the llvm-bugs
mailing list