public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/52440] New: [C++11] Wrong template argument deduction/substitution failures
@ 2012-02-29 20:33 ai.azuma at gmail dot com
  2013-06-10 15:52 ` [Bug c++/52440] " paolo.carlini at oracle dot com
  2013-06-10 16:08 ` paolo.carlini at oracle dot com
  0 siblings, 2 replies; 3+ messages in thread
From: ai.azuma at gmail dot com @ 2012-02-29 20:33 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52440
           Summary: [C++11] Wrong template argument deduction/substitution
                    failures
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: ai.azuma@gmail.com


Created attachment 26790
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26790
Output of -v option and preprocessed file

I can't find anything to prevent the following code from compiling;

/////////////////////////////////////////////////////////
template<bool>
struct V
{
  typedef void type;
};

template<typename T>
struct X
{
  template<typename>
  static constexpr bool always_true()
  {
    return true;
  };

  template<typename U,
           typename = typename V<always_true<U>()>::type>
  X(U &&) {}    // Line 18
};

int main()
{
  X<int> x(42); // Line 23
}
/////////////////////////////////////////////////////////

However, GCC complains about deduction/substitution failure;

main.cpp: In function 'int main()':
main.cpp:23:14: error: no matching function for call to 'X<int>::X(int)'
main.cpp:23:14: note: candidates are:
main.cpp:18:3: note: template<class U, class> X::X(U&&)
main.cpp:18:3: note:   template argument deduction/substitution failed:
main.cpp:8:8: note: constexpr X<int>::X(const X<int>&)
main.cpp:8:8: note:   no known conversion for argument 1 from 'int' to 'const
X<int>&'
main.cpp:8:8: note: constexpr X<int>::X(X<int>&&)
main.cpp:8:8: note:   no known conversion for argument 1 from 'int' to
'X<int>&&'

The constructor template in line 18 should always succeed in template argument
deduction/substitution and be used for the invocation in Line 23.

My guess is that this is a bug of GCC.


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

* [Bug c++/52440] [C++11] Wrong template argument deduction/substitution failures
  2012-02-29 20:33 [Bug c++/52440] New: [C++11] Wrong template argument deduction/substitution failures ai.azuma at gmail dot com
@ 2013-06-10 15:52 ` paolo.carlini at oracle dot com
  2013-06-10 16:08 ` paolo.carlini at oracle dot com
  1 sibling, 0 replies; 3+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-06-10 15:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Fixed in 4.7.3. I'm adding the testcase and closing the bug.


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

* [Bug c++/52440] [C++11] Wrong template argument deduction/substitution failures
  2012-02-29 20:33 [Bug c++/52440] New: [C++11] Wrong template argument deduction/substitution failures ai.azuma at gmail dot com
  2013-06-10 15:52 ` [Bug c++/52440] " paolo.carlini at oracle dot com
@ 2013-06-10 16:08 ` paolo.carlini at oracle dot com
  1 sibling, 0 replies; 3+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-06-10 16:08 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
      Known to work|                            |4.7.3, 4.8.0, 4.9.0
         Resolution|---                         |FIXED
   Target Milestone|---                         |4.7.3

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Done.


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

end of thread, other threads:[~2013-06-10 16:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-29 20:33 [Bug c++/52440] New: [C++11] Wrong template argument deduction/substitution failures ai.azuma at gmail dot com
2013-06-10 15:52 ` [Bug c++/52440] " paolo.carlini at oracle dot com
2013-06-10 16:08 ` 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).