public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/45012]  New: Invalid ambiguity on partial class specialization matching
@ 2010-07-21  2:43 rodolfo at rodsoft dot org
  2010-07-21  2:49 ` [Bug c++/45012] " rodolfo at rodsoft dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: rodolfo at rodsoft dot org @ 2010-07-21  2:43 UTC (permalink / raw)
  To: gcc-bugs

The following code doesn't compile unless variable RUNTIME is defined as a
"static const int" instead of an "enum":

#include <type_traits>

enum { RUNTIME = 0 };
// it compiles with the previous line commented out and the next commented in
// static const int RUNTIME=0;

template <class T, class U, class EN=void> struct foo;

template <template<int> class V, int M>
struct foo<V<M>,V<M>, typename std::enable_if<M==RUNTIME || M==2>::type> {};

template <template<int> class V1, template<int> class V2, int M>
struct foo<V1<M>,V2<M>, typename std::enable_if<M==RUNTIME || M==2>::type> {};

template <int M> struct bar {};

foo<bar<2>,bar<2>> x;


-- 
           Summary: Invalid ambiguity on partial class specialization
                    matching
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rodolfo at rodsoft dot org
 GCC build triplet: x86_64-pc-linux-gnu
  GCC host triplet: x86_64-pc-linux-gnu
GCC target triplet: x86_64-pc-linux-gnu


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


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

* [Bug c++/45012] Invalid ambiguity on partial class specialization matching
  2010-07-21  2:43 [Bug c++/45012] New: Invalid ambiguity on partial class specialization matching rodolfo at rodsoft dot org
@ 2010-07-21  2:49 ` rodolfo at rodsoft dot org
  2010-07-21  2:53 ` [Bug c++/45012] New: " Andrew Pinski
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: rodolfo at rodsoft dot org @ 2010-07-21  2:49 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1338 bytes --]



------- Comment #1 from rodolfo at rodsoft dot org  2010-07-21 02:49 -------
The code I posted was meant to be compiled in c++0x mode, but if we write
directly the definition of std::enable_if, it also happens in c++03 mode.
So, instead of #include <type_traits>, one should write:

template <bool B, class T=void> struct enable_if;

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

Of course, I forgot to add the error messages:

teste.cpp:30: error: ambiguous class template instantiation for ‘struct
foo<bar<2>, bar<2>, void>’
teste.cpp:19: error: candidates are: struct foo<V<M>, V<M>, typename
enable_if<((M == RUNTIME) || (M == 2)), void>::type>
teste.cpp:25: error:                 struct foo<V1<M>, V2<M>, typename
enable_if<((M == RUNTIME) || (M == 2)), void>::type>
teste.cpp:30: error: aggregate ‘foo<bar<2>, bar<2>, void> x’ has incomplete
type and cannot be defined


-- 

rodolfo at rodsoft dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rodolfo at rodsoft dot org
           Keywords|                            |rejects-valid
      Known to fail|                            |4.4.3 4.5.0


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


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

* Re: [Bug c++/45012]  New: Invalid ambiguity on partial class specialization matching
  2010-07-21  2:43 [Bug c++/45012] New: Invalid ambiguity on partial class specialization matching rodolfo at rodsoft dot org
  2010-07-21  2:49 ` [Bug c++/45012] " rodolfo at rodsoft dot org
@ 2010-07-21  2:53 ` Andrew Pinski
  2010-07-21  2:54 ` [Bug c++/45012] " pinskia at gmail dot com
  2010-07-21  3:03 ` rodolfo at rodsoft dot org
  3 siblings, 0 replies; 8+ messages in thread
From: Andrew Pinski @ 2010-07-21  2:53 UTC (permalink / raw)
  To: gcc-bugzilla; +Cc: gcc-bugs



On Jul 20, 2010, at 7:43 PM, "rodolfo at rodsoft dot org" <gcc-bugzilla@gcc.gnu.org 
 > wrote:

> The following code doesn't compile unless variable RUNTIME is  
> defined as a
> "static const int" instead of an "enum":
>

This enum value has an anonymous type which is not valid in the  
context of templates in C++03/98. It is valid in the current draft of C 
++0x though. But I cannot remember if 4.5 implements that rule for - 
std=gnu++0x (-std=c++0x).



> #include <type_traits>
>
> enum { RUNTIME = 0 };
> // it compiles with the previous line commented out and the next  
> commented in
> // static const int RUNTIME=0;
>
> template <class T, class U, class EN=void> struct foo;
>
> template <template<int> class V, int M>
> struct foo<V<M>,V<M>, typename std::enable_if<M==RUNTIME ||  
> M==2>::type> {};
>
> template <template<int> class V1, template<int> class V2, int M>
> struct foo<V1<M>,V2<M>, typename std::enable_if<M==RUNTIME ||  
> M==2>::type> {};
>
> template <int M> struct bar {};
>
> foo<bar<2>,bar<2>> x;
>
>
> -- 
>           Summary: Invalid ambiguity on partial class specialization
>                    matching
>           Product: gcc
>           Version: 4.5.0
>            Status: UNCONFIRMED
>          Severity: normal
>          Priority: P3
>         Component: c++
>        AssignedTo: unassigned at gcc dot gnu dot org
>        ReportedBy: rodolfo at rodsoft dot org
> GCC build triplet: x86_64-pc-linux-gnu
>  GCC host triplet: x86_64-pc-linux-gnu
> GCC target triplet: x86_64-pc-linux-gnu
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45012
>


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

* [Bug c++/45012] Invalid ambiguity on partial class specialization matching
  2010-07-21  2:43 [Bug c++/45012] New: Invalid ambiguity on partial class specialization matching rodolfo at rodsoft dot org
  2010-07-21  2:49 ` [Bug c++/45012] " rodolfo at rodsoft dot org
  2010-07-21  2:53 ` [Bug c++/45012] New: " Andrew Pinski
@ 2010-07-21  2:54 ` pinskia at gmail dot com
  2010-07-21  3:03 ` rodolfo at rodsoft dot org
  3 siblings, 0 replies; 8+ messages in thread
From: pinskia at gmail dot com @ 2010-07-21  2:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gmail dot com  2010-07-21 02:53 -------
Subject: Re:   New: Invalid ambiguity on partial class specialization matching



On Jul 20, 2010, at 7:43 PM, "rodolfo at rodsoft dot org"
<gcc-bugzilla@gcc.gnu.org 
 > wrote:

> The following code doesn't compile unless variable RUNTIME is  
> defined as a
> "static const int" instead of an "enum":
>

This enum value has an anonymous type which is not valid in the  
context of templates in C++03/98. It is valid in the current draft of C 
++0x though. But I cannot remember if 4.5 implements that rule for - 
std=gnu++0x (-std=c++0x).



> #include <type_traits>
>
> enum { RUNTIME = 0 };
> // it compiles with the previous line commented out and the next  
> commented in
> // static const int RUNTIME=0;
>
> template <class T, class U, class EN=void> struct foo;
>
> template <template<int> class V, int M>
> struct foo<V<M>,V<M>, typename std::enable_if<M==RUNTIME ||  
> M==2>::type> {};
>
> template <template<int> class V1, template<int> class V2, int M>
> struct foo<V1<M>,V2<M>, typename std::enable_if<M==RUNTIME ||  
> M==2>::type> {};
>
> template <int M> struct bar {};
>
> foo<bar<2>,bar<2>> x;
>
>
> -- 
>           Summary: Invalid ambiguity on partial class specialization
>                    matching
>           Product: gcc
>           Version: 4.5.0
>            Status: UNCONFIRMED
>          Severity: normal
>          Priority: P3
>         Component: c++
>        AssignedTo: unassigned at gcc dot gnu dot org
>        ReportedBy: rodolfo at rodsoft dot org
> GCC build triplet: x86_64-pc-linux-gnu
>  GCC host triplet: x86_64-pc-linux-gnu
> GCC target triplet: x86_64-pc-linux-gnu
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45012
>


-- 


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


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

* [Bug c++/45012] Invalid ambiguity on partial class specialization matching
  2010-07-21  2:43 [Bug c++/45012] New: Invalid ambiguity on partial class specialization matching rodolfo at rodsoft dot org
                   ` (2 preceding siblings ...)
  2010-07-21  2:54 ` [Bug c++/45012] " pinskia at gmail dot com
@ 2010-07-21  3:03 ` rodolfo at rodsoft dot org
  3 siblings, 0 replies; 8+ messages in thread
From: rodolfo at rodsoft dot org @ 2010-07-21  3:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rodolfo at rodsoft dot org  2010-07-21 03:03 -------
(In reply to comment #2)
> This enum value has an anonymous type which is not valid in the  
> context of templates in C++03/98. It is valid in the current draft of C 
> ++0x though. But I cannot remember if 4.5 implements that rule for - 
> std=gnu++0x (-std=c++0x).

But I'm not using that anonymous type for template argument deduction (i.e.:
foo<bar<RUNTIME>,bar<RUNTIME>>), I'm just using in a comparison with an int.
But even if I turn it into a named type (i.e.: enum value_t { RUNTIME=-1 };),
it doesn't compile.


-- 


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


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

* [Bug c++/45012] Invalid ambiguity on partial class specialization matching
       [not found] <bug-45012-4@http.gcc.gnu.org/bugzilla/>
  2011-09-26 18:31 ` paolo.carlini at oracle dot com
  2011-09-27  2:40 ` jason at gcc dot gnu.org
@ 2011-11-17 16:11 ` ramana at gcc dot gnu.org
  2 siblings, 0 replies; 8+ messages in thread
From: ramana at gcc dot gnu.org @ 2011-11-17 16:11 UTC (permalink / raw)
  To: gcc-bugs

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

Ramana Radhakrishnan <ramana at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ramana at gcc dot gnu.org

--- Comment #6 from Ramana Radhakrishnan <ramana at gcc dot gnu.org> 2011-11-17 16:03:34 UTC ---
It was fixed actually by this commit . 

Author: jason
Date: Tue Sep 27 02:13:00 2011
New Revision: 179230

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=179230
Log:
    PR c++/45102
    * pt.c (tsubst_copy_and_build) [CONST_DECL]: Don't pull out
    constant value if we're still in a template.

Added:
    trunk/gcc/testsuite/g++.dg/template/partial13.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/45012] Invalid ambiguity on partial class specialization matching
       [not found] <bug-45012-4@http.gcc.gnu.org/bugzilla/>
  2011-09-26 18:31 ` paolo.carlini at oracle dot com
@ 2011-09-27  2:40 ` jason at gcc dot gnu.org
  2011-11-17 16:11 ` ramana at gcc dot gnu.org
  2 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2011-09-27  2:40 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |jason at gcc dot gnu.org
         Resolution|                            |FIXED
         AssignedTo|unassigned at gcc dot       |jason at gcc dot gnu.org
                   |gnu.org                     |
   Target Milestone|---                         |4.7.0
      Known to fail|                            |

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> 2011-09-27 02:22:29 UTC ---
Fixed for 4.7.


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

* [Bug c++/45012] Invalid ambiguity on partial class specialization matching
       [not found] <bug-45012-4@http.gcc.gnu.org/bugzilla/>
@ 2011-09-26 18:31 ` paolo.carlini at oracle dot com
  2011-09-27  2:40 ` jason at gcc dot gnu.org
  2011-11-17 16:11 ` ramana at gcc dot gnu.org
  2 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-09-26 18:31 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |potswa at mac dot com

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-09-26 18:28:15 UTC ---
*** Bug 46105 has been marked as a duplicate of this bug. ***


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

end of thread, other threads:[~2011-11-17 16:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-21  2:43 [Bug c++/45012] New: Invalid ambiguity on partial class specialization matching rodolfo at rodsoft dot org
2010-07-21  2:49 ` [Bug c++/45012] " rodolfo at rodsoft dot org
2010-07-21  2:53 ` [Bug c++/45012] New: " Andrew Pinski
2010-07-21  2:54 ` [Bug c++/45012] " pinskia at gmail dot com
2010-07-21  3:03 ` rodolfo at rodsoft dot org
     [not found] <bug-45012-4@http.gcc.gnu.org/bugzilla/>
2011-09-26 18:31 ` paolo.carlini at oracle dot com
2011-09-27  2:40 ` jason at gcc dot gnu.org
2011-11-17 16:11 ` ramana at gcc dot gnu.org

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