public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/26205] New: pointer to member template parameter can't be null
@ 2006-02-10 1:08 jeffp at doomsday dot org
2006-02-10 1:19 ` [Bug c++/26205] " pinskia at gcc dot gnu dot org
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: jeffp at doomsday dot org @ 2006-02-10 1:08 UTC (permalink / raw)
To: gcc-bugs
struct Simple
{
int a;
};
template <typename T, int T::*U> struct Test
{
void Foo(T *obj, int v)
{
if (U != 0)
obj->*U = v;
}
};
int main(int argc, const char **argv)
{
Test<Simple, &Simple::a> t1; // ok
Test<Simple, 0> t2; // error, but should not be (works in MSVC
7/8)
Simple s;
t1.Foo(&s, 5);
}
Note: it also won't let you specify a default parameter of 0 for the template
parameter:
template <typename T, int T::*U = 0> struct Test // won't do this either
MSVC 7/8 handle the first case, but also can't handle the default parameter
(they crash with an internal compiler error). MSVC 7/8 also won't handle
specialization of the Foo function for the 0 case, though the resultant code
generated is the same since the branch is optimized out. I only mention this
to give you some other nuances to check for once the base bug is fixed.
--
Summary: pointer to member template parameter can't be null
Product: gcc
Version: 3.4.4
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jeffp at doomsday dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26205
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/26205] pointer to member template parameter can't be null
2006-02-10 1:08 [Bug c++/26205] New: pointer to member template parameter can't be null jeffp at doomsday dot org
@ 2006-02-10 1:19 ` pinskia at gcc dot gnu dot org
2006-02-15 19:37 ` bangerth at dealii dot org
2006-02-15 19:55 ` jeffp at doomsday dot org
2 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-02-10 1:19 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2006-02-10 01:19 -------
Comeau gives the following error:
"ComeauTest.c", line 19: error: argument of type "int" is incompatible with
template parameter of type "int Simple::*"
Test<Simple, NULL> t2; // error, but should not be (works in
^
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26205
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/26205] pointer to member template parameter can't be null
2006-02-10 1:08 [Bug c++/26205] New: pointer to member template parameter can't be null jeffp at doomsday dot org
2006-02-10 1:19 ` [Bug c++/26205] " pinskia at gcc dot gnu dot org
@ 2006-02-15 19:37 ` bangerth at dealii dot org
2006-02-15 19:55 ` jeffp at doomsday dot org
2 siblings, 0 replies; 5+ messages in thread
From: bangerth at dealii dot org @ 2006-02-15 19:37 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from bangerth at dealii dot org 2006-02-15 19:37 -------
icc gives essentially the same error as that one mentioned by Andrew for
Comeau (not surprisingly). As a workaround, you can always use an explicit
cast:
Test<Simple, (int Simple::*)0> t2;
I believe the code is ok anyway, see 4.11/1.
W.
--
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2006-02-15 19:37:18
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26205
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/26205] pointer to member template parameter can't be null
2006-02-10 1:08 [Bug c++/26205] New: pointer to member template parameter can't be null jeffp at doomsday dot org
2006-02-10 1:19 ` [Bug c++/26205] " pinskia at gcc dot gnu dot org
2006-02-15 19:37 ` bangerth at dealii dot org
@ 2006-02-15 19:55 ` jeffp at doomsday dot org
2 siblings, 0 replies; 5+ messages in thread
From: jeffp at doomsday dot org @ 2006-02-15 19:55 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from jeffp at doomsday dot org 2006-02-15 19:55 -------
The casting work-around doesn't compile under GCC. It requires that the
template parameter be a constant-expression (which is true), which results in
the following error:
error: a casts to a type other than an integral or enumeration type cannot
appear in a constant-expression
I have yet to be able to figure out a work-around. MSVC allows the cast, but
works with or without it.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26205
^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <bug-26205-4@http.gcc.gnu.org/bugzilla/>]
end of thread, other threads:[~2013-11-15 18:05 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-10 1:08 [Bug c++/26205] New: pointer to member template parameter can't be null jeffp at doomsday dot org
2006-02-10 1:19 ` [Bug c++/26205] " pinskia at gcc dot gnu dot org
2006-02-15 19:37 ` bangerth at dealii dot org
2006-02-15 19:55 ` jeffp at doomsday dot org
[not found] <bug-26205-4@http.gcc.gnu.org/bugzilla/>
2013-11-15 18:05 ` paolo.carlini at oracle dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).