public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/26605]  New: enable_if + using troubles
@ 2006-03-08 13:43 pcarlini at suse dot de
  2006-03-08 13:57 ` [Bug c++/26605] using + templates troubles pcarlini at suse dot de
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: pcarlini at suse dot de @ 2006-03-08 13:43 UTC (permalink / raw)
  To: gcc-bugs

EDG-based compilers accept (in strict mode) accept this:

template<typename T>
  struct is_void
  { static const bool value = false; };

template<>
  struct is_void<void>
  { static const bool value = true; };

template<typename, bool>
  struct enable_if { };

template<typename T>
  struct enable_if<T, true>
  { typedef T type; };

namespace one
{
  template<typename T>
    typename enable_if<double, is_void<T>::value>::type
    fun(T);
}

namespace two
{
  using one::fun;

  template<typename T>
    typename enable_if<double, !is_void<T>::value>::type
    fun(T);
}

/////////////

paolo:~/Work> g++ -c reduced.cc
reduced.cc:29: error: 'template<class T> typename enable_if<double, (!
is_void<T>::value)>::type two::fun(T)' conflicts with previous using
declaration 'template<class T> typename enable_if<double,
is_void<T>::value>::type one::fun(T)'


-- 
           Summary: enable_if + using troubles
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pcarlini at suse dot de


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26605


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/26605] using + templates troubles
  2006-03-08 13:43 [Bug c++/26605] New: enable_if + using troubles pcarlini at suse dot de
@ 2006-03-08 13:57 ` pcarlini at suse dot de
  2006-03-08 14:01 ` pcarlini at suse dot de
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pcarlini at suse dot de @ 2006-03-08 13:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pcarlini at suse dot de  2006-03-08 13:57 -------
Actually, the issue seems much simpler:

namespace one
{
  template<typename T>
    void
    fun(T);
}

using one::fun;

template<typename T>
  void
  fun(T);

////////////

paolo:~/Work> g++ -c reduced2.cc
reduced2.cc:12: error: 'template<class T> void fun(T)' conflicts with previous
using declaration 'template<class T> void one::fun(T)'


-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|enable_if + using troubles  |using + templates troubles


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26605


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/26605] using + templates troubles
  2006-03-08 13:43 [Bug c++/26605] New: enable_if + using troubles pcarlini at suse dot de
  2006-03-08 13:57 ` [Bug c++/26605] using + templates troubles pcarlini at suse dot de
@ 2006-03-08 14:01 ` pcarlini at suse dot de
  2006-03-08 14:07 ` pinskia at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pcarlini at suse dot de @ 2006-03-08 14:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pcarlini at suse dot de  2006-03-08 14:01 -------
Likely a duplicate of c++/21682, but simpler testcase ;)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26605


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/26605] using + templates troubles
  2006-03-08 13:43 [Bug c++/26605] New: enable_if + using troubles pcarlini at suse dot de
  2006-03-08 13:57 ` [Bug c++/26605] using + templates troubles pcarlini at suse dot de
  2006-03-08 14:01 ` pcarlini at suse dot de
@ 2006-03-08 14:07 ` pinskia at gcc dot gnu dot org
  2006-03-08 14:11 ` pcarlini at suse dot de
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-08 14:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2006-03-08 14:07 -------
(In reply to comment #2)
> Likely a duplicate of c++/21682, but simpler testcase ;)

I don't know how that and comment #1 are valid code as in both cases the
arguments will be the same so you should get an error about ambiguous
functions.

Now the one in comment #0 is slightly different as the enable if causes a
specific function to be selected.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26605


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/26605] using + templates troubles
  2006-03-08 13:43 [Bug c++/26605] New: enable_if + using troubles pcarlini at suse dot de
                   ` (2 preceding siblings ...)
  2006-03-08 14:07 ` pinskia at gcc dot gnu dot org
@ 2006-03-08 14:11 ` pcarlini at suse dot de
  2006-03-08 14:15 ` pcarlini at suse dot de
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pcarlini at suse dot de @ 2006-03-08 14:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pcarlini at suse dot de  2006-03-08 14:11 -------
(In reply to comment #3)
> (In reply to comment #2)
> > Likely a duplicate of c++/21682, but simpler testcase ;)
> 
> I don't know how that and comment #1 are valid code as in both cases the
> arguments will be the same so you should get an error about ambiguous
> functions.

Not so early, I think, because T is unknown.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26605


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/26605] using + templates troubles
  2006-03-08 13:43 [Bug c++/26605] New: enable_if + using troubles pcarlini at suse dot de
                   ` (3 preceding siblings ...)
  2006-03-08 14:11 ` pcarlini at suse dot de
@ 2006-03-08 14:15 ` pcarlini at suse dot de
  2006-03-08 14:21 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pcarlini at suse dot de @ 2006-03-08 14:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pcarlini at suse dot de  2006-03-08 14:15 -------
(In reply to comment #4)
> > I don't know how that and comment #1 are valid code as in both cases the
> > arguments will be the same so you should get an error about ambiguous
> > functions.
> 
> Not so early, I think, because T is unknown.

And, by the way, this one already compiles:

template<typename T>
  void
  fun(T);

template<typename T>
  void
  fun(T);


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26605


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/26605] using + templates troubles
  2006-03-08 13:43 [Bug c++/26605] New: enable_if + using troubles pcarlini at suse dot de
                   ` (4 preceding siblings ...)
  2006-03-08 14:15 ` pcarlini at suse dot de
@ 2006-03-08 14:21 ` pinskia at gcc dot gnu dot org
  2006-03-08 14:24 ` pcarlini at suse dot de
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-08 14:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pinskia at gcc dot gnu dot org  2006-03-08 14:21 -------
(In reply to comment #5)
> And, by the way, this one already compiles:
But that names the same function, it is just like:
int f(void);
int f(void);


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26605


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/26605] using + templates troubles
  2006-03-08 13:43 [Bug c++/26605] New: enable_if + using troubles pcarlini at suse dot de
                   ` (5 preceding siblings ...)
  2006-03-08 14:21 ` pinskia at gcc dot gnu dot org
@ 2006-03-08 14:24 ` pcarlini at suse dot de
  2006-03-08 14:56 ` pcarlini at suse dot de
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pcarlini at suse dot de @ 2006-03-08 14:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pcarlini at suse dot de  2006-03-08 14:24 -------
(In reply to comment #6)
> (In reply to comment #5)
> > And, by the way, this one already compiles:
> But that names the same function, it is just like:
> int f(void);
> int f(void);

No, it's not the same, because we are dealing with the templates. I'm going to
study the standard (maybe you can also do that ;) but we have an hard fact:
both g++ and EDG accept the version without using, only g++ rejects that with
using.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26605


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/26605] using + templates troubles
  2006-03-08 13:43 [Bug c++/26605] New: enable_if + using troubles pcarlini at suse dot de
                   ` (6 preceding siblings ...)
  2006-03-08 14:24 ` pcarlini at suse dot de
@ 2006-03-08 14:56 ` pcarlini at suse dot de
  2006-03-08 16:20 ` [Bug c++/26605] using + function " pcarlini at suse dot de
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pcarlini at suse dot de @ 2006-03-08 14:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from pcarlini at suse dot de  2006-03-08 14:56 -------
(In reply to comment #7)
> No, it's not the same, because we are dealing with the templates. I'm going to
> study the standard (maybe you can also do that ;) but we have an hard fact:
> both g++ and EDG accept the version without using, only g++ rejects that with
> using.

In my opinion, 14.8.3 is sufficient to say that the simple snippets in Comments
#1 and #5 should both compile (only #5 is already ok on GCC): only when a call
to the name is written template argument deduction takes place, separately for
each function template, then overload resolution is performed (which would of
course fails, in the examples), no earlier checks should be carried out.


-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-03-08 14:56:52
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26605


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/26605] using + function templates troubles
  2006-03-08 13:43 [Bug c++/26605] New: enable_if + using troubles pcarlini at suse dot de
                   ` (7 preceding siblings ...)
  2006-03-08 14:56 ` pcarlini at suse dot de
@ 2006-03-08 16:20 ` pcarlini at suse dot de
  2006-03-08 22:28 ` mmitchel at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pcarlini at suse dot de @ 2006-03-08 16:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from pcarlini at suse dot de  2006-03-08 16:20 -------
The below also works already (can make for an useful if ugly workaround, in
some cases, e.g., c++/21682):

namespace one
{
  template<typename T>
    void
    fun(T);
}

namespace two
{
  template<typename T>
    void
    fun(T);
}

using one::fun;
using two::fun;


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26605


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/26605] using + function templates troubles
  2006-03-08 13:43 [Bug c++/26605] New: enable_if + using troubles pcarlini at suse dot de
                   ` (8 preceding siblings ...)
  2006-03-08 16:20 ` [Bug c++/26605] using + function " pcarlini at suse dot de
@ 2006-03-08 22:28 ` mmitchel at gcc dot gnu dot org
  2006-03-08 22:36 ` pcarlini at suse dot de
  2006-03-10  9:38 ` pcarlini at suse dot de
  11 siblings, 0 replies; 13+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-03-08 22:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from mmitchel at gcc dot gnu dot org  2006-03-08 22:28 -------
I think the code in Comment #1 is unambiguously invalid.

7.3.3/11 says says that a function declaration in namespace scope may not match
the declaration of a function introduced by a using declaration; i.e., the
following:

  namespace N { void f(); };
  using N::f;
  void f();

is invalid.  Making the functions templates does not change that.  That
paragraph also makes clear that the code in Comment #9 is valid.  I don't see
any DRs that suggest changes in this area.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26605


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/26605] using + function templates troubles
  2006-03-08 13:43 [Bug c++/26605] New: enable_if + using troubles pcarlini at suse dot de
                   ` (9 preceding siblings ...)
  2006-03-08 22:28 ` mmitchel at gcc dot gnu dot org
@ 2006-03-08 22:36 ` pcarlini at suse dot de
  2006-03-10  9:38 ` pcarlini at suse dot de
  11 siblings, 0 replies; 13+ messages in thread
From: pcarlini at suse dot de @ 2006-03-08 22:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from pcarlini at suse dot de  2006-03-08 22:36 -------
Hum, I see. Therefore c++/21682 is also invalid? And EDG too, apparently ;)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26605


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/26605] using + function templates troubles
  2006-03-08 13:43 [Bug c++/26605] New: enable_if + using troubles pcarlini at suse dot de
                   ` (10 preceding siblings ...)
  2006-03-08 22:36 ` pcarlini at suse dot de
@ 2006-03-10  9:38 ` pcarlini at suse dot de
  11 siblings, 0 replies; 13+ messages in thread
From: pcarlini at suse dot de @ 2006-03-10  9:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from pcarlini at suse dot de  2006-03-10 09:38 -------
I sent a message to the CWG reflector, and people kindly replied
(c++std-core-11367 to 11370). In a nutshell, 7.3.3/11 should be clarified for
function templates (a new issue has been opened), but apparently there is
consensus that Comment #1 below is invalid while Comment #0 is fine (because
the return types are different, and return types matter for function templates
[14.5.5.1p4]). However, the first snippet is actually the same issue of
c++/21682 and therefore I'm closing this one as duplicate.

*** This bug has been marked as a duplicate of 21682 ***


-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26605


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2006-03-10  9:38 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-08 13:43 [Bug c++/26605] New: enable_if + using troubles pcarlini at suse dot de
2006-03-08 13:57 ` [Bug c++/26605] using + templates troubles pcarlini at suse dot de
2006-03-08 14:01 ` pcarlini at suse dot de
2006-03-08 14:07 ` pinskia at gcc dot gnu dot org
2006-03-08 14:11 ` pcarlini at suse dot de
2006-03-08 14:15 ` pcarlini at suse dot de
2006-03-08 14:21 ` pinskia at gcc dot gnu dot org
2006-03-08 14:24 ` pcarlini at suse dot de
2006-03-08 14:56 ` pcarlini at suse dot de
2006-03-08 16:20 ` [Bug c++/26605] using + function " pcarlini at suse dot de
2006-03-08 22:28 ` mmitchel at gcc dot gnu dot org
2006-03-08 22:36 ` pcarlini at suse dot de
2006-03-10  9:38 ` pcarlini at suse dot de

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).