public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/44969]  New: [C++0x] <type_traits> std::is_constructible broken for fundamental types.
@ 2010-07-17  0:01 piotr dot rak at gmail dot com
  2010-07-17  0:03 ` [Bug libstdc++/44969] " piotr dot rak at gmail dot com
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: piotr dot rak at gmail dot com @ 2010-07-17  0:01 UTC (permalink / raw)
  To: gcc-bugs

cat is_constructible_bug.cc && g++-trunk -v -c -std=c++0x
is_constructible_bug.cc 
#include <type_traits>

class allocator_arg_t {};

class A {};

// From n3092: [allocator.uses.construction] 20.9.2.2 p1.2
//  (2nd part of condition, in FCD use case first part never true)
template <typename X, typename Alloc, typename... Args>
struct alloc_arg_1st : 
    std::is_constructible<X, ::allocator_arg_t, Alloc, Args...>
{
};

bool foo()
{
    struct B {};
    bool val = alloc_arg_1st<B, A>::value;// ok
    return val || alloc_arg_1st<int, A>::value; // bang
}
Using built-in specs.
COLLECT_GCC=/home/prak/Dev/gcc-install/bin/g++-trunk
COLLECT_LTO_WRAPPER=/home/prak/Dev/gcc-install/libexec/gcc/i686-pc-linux-gnu/4.6.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../gcc.git/configure --enable-languages=c,c++
--program-suffix=-trunk --prefix=/home/prak/Dev/gcc-install --disable-bootstrap
Thread model: posix
gcc version 4.6.0 20100716 (experimental) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-c' '-std=c++0x' '-shared-libgcc' '-mtune=generic'
'-march=pentiumpro'
 /home/prak/Dev/gcc-install/libexec/gcc/i686-pc-linux-gnu/4.6.0/cc1plus -quiet
-v -D_GNU_SOURCE is_constructible_bug.cc -quiet -dumpbase
is_constructible_bug.cc -mtune=generic -march=pentiumpro -auxbase
is_constructible_bug -std=c++0x -version -o /tmp/ccocsKE0.s
GNU C++ (GCC) version 4.6.0 20100716 (experimental) (i686-pc-linux-gnu)
        compiled by GNU C version 4.3.4, GMP version 4.3.2, MPFR version 3.0.0,
MPC version 0.8.2
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory
"/home/prak/Dev/gcc-install/lib/gcc/i686-pc-linux-gnu/4.6.0/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:

/home/prak/Dev/gcc-install/lib/gcc/i686-pc-linux-gnu/4.6.0/../../../../include/c++/4.6.0

/home/prak/Dev/gcc-install/lib/gcc/i686-pc-linux-gnu/4.6.0/../../../../include/c++/4.6.0/i686-pc-linux-gnu

/home/prak/Dev/gcc-install/lib/gcc/i686-pc-linux-gnu/4.6.0/../../../../include/c++/4.6.0/backward
 /home/prak/Dev/gcc-install/include
 /home/prak/Dev/gcc-install/lib/gcc/i686-pc-linux-gnu/4.6.0/include
 /home/prak/Dev/gcc-install/lib/gcc/i686-pc-linux-gnu/4.6.0/include-fixed
 /usr/include
End of search list.
GNU C++ (GCC) version 4.6.0 20100716 (experimental) (i686-pc-linux-gnu)
        compiled by GNU C version 4.3.4, GMP version 4.3.2, MPFR version 3.0.0,
MPC version 0.8.2
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 6d1c47967936e3e68fa845533411d5d9
In file included from is_constructible_bug.cc:1:0:
/home/prak/Dev/gcc-install/lib/gcc/i686-pc-linux-gnu/4.6.0/../../../../include/c++/4.6.0/type_traits:
In instantiation of &#8216;const bool std::__is_constructible_helper<int,
allocator_arg_t, A>::__value&#8217;:
/home/prak/Dev/gcc-install/lib/gcc/i686-pc-linux-gnu/4.6.0/../../../../include/c++/4.6.0/type_traits:231:12:
  instantiated from &#8216;std::is_constructible<int, allocator_arg_t,
A>&#8217;
is_constructible_bug.cc:10:8:   instantiated from &#8216;alloc_arg_1st<int,
A>&#8217;
is_constructible_bug.cc:19:40:   instantiated from here
/home/prak/Dev/gcc-install/lib/gcc/i686-pc-linux-gnu/4.6.0/../../../../include/c++/4.6.0/type_traits:209:71:
error: expression list treated as compound expression in functional cast
[-fpermissive]


-- 
           Summary: [C++0x] <type_traits> std::is_constructible broken for
                    fundamental types.
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: piotr dot rak at gmail dot com


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


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

* [Bug libstdc++/44969] [C++0x] <type_traits> std::is_constructible broken for fundamental types.
  2010-07-17  0:01 [Bug libstdc++/44969] New: [C++0x] <type_traits> std::is_constructible broken for fundamental types piotr dot rak at gmail dot com
@ 2010-07-17  0:03 ` piotr dot rak at gmail dot com
  2010-07-17  0:56 ` paolo dot carlini at oracle dot com
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: piotr dot rak at gmail dot com @ 2010-07-17  0:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from piotr dot rak at gmail dot com  2010-07-17 00:03 -------
Created an attachment (id=21233)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21233&action=view)
Testcase


-- 


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


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

* [Bug libstdc++/44969] [C++0x] <type_traits> std::is_constructible broken for fundamental types.
  2010-07-17  0:01 [Bug libstdc++/44969] New: [C++0x] <type_traits> std::is_constructible broken for fundamental types piotr dot rak at gmail dot com
  2010-07-17  0:03 ` [Bug libstdc++/44969] " piotr dot rak at gmail dot com
@ 2010-07-17  0:56 ` paolo dot carlini at oracle dot com
  2010-07-17 19:05 ` [Bug c++/44969] " paolo dot carlini at oracle dot com
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-07-17  0:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from paolo dot carlini at oracle dot com  2010-07-17 00:56 -------
I don't think this is a library issue, the implementation is straightforward.
The below C++03 snippet already shows the problem, is rejected (ICC likes it).

Jason, can you have a look to this one too?

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

template<bool, typename T = void> struct enable_if { typedef T type; };
template<typename T> struct enable_if<false, T> { };

template<typename Tp, typename Arg1, typename Arg2>
  class mini_is_constructible
  {
    typedef char one;
    typedef struct { char arr[2]; } two;

    template<typename Tp1, typename Arg1_, typename Arg2_>
      static typename
      enable_if<(sizeof(Tp1(Arg1_(), Arg2_()), 1) > 0), one>::type
      test(int);

    template<typename, typename, typename>
      static two test(...);

  public:
    static const bool value = sizeof(test<Tp, Arg1, Arg2>(0)) == 1;
  };

class A { };

int Test[mini_is_constructible<int, A, A>::value ? -1 : 1];


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu dot org


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


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

* [Bug c++/44969] [C++0x] <type_traits> std::is_constructible broken for fundamental types.
  2010-07-17  0:01 [Bug libstdc++/44969] New: [C++0x] <type_traits> std::is_constructible broken for fundamental types piotr dot rak at gmail dot com
  2010-07-17  0:03 ` [Bug libstdc++/44969] " piotr dot rak at gmail dot com
  2010-07-17  0:56 ` paolo dot carlini at oracle dot com
@ 2010-07-17 19:05 ` paolo dot carlini at oracle dot com
  2010-07-17 19:14 ` paolo dot carlini at oracle dot com
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-07-17 19:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from paolo dot carlini at oracle dot com  2010-07-17 19:05 -------
Created an attachment (id=21236)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21236&action=view)
Draft patch for the original testcase


-- 


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


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

* [Bug c++/44969] [C++0x] <type_traits> std::is_constructible broken for fundamental types.
  2010-07-17  0:01 [Bug libstdc++/44969] New: [C++0x] <type_traits> std::is_constructible broken for fundamental types piotr dot rak at gmail dot com
                   ` (2 preceding siblings ...)
  2010-07-17 19:05 ` [Bug c++/44969] " paolo dot carlini at oracle dot com
@ 2010-07-17 19:14 ` paolo dot carlini at oracle dot com
  2010-07-17 19:14 ` paolo dot carlini at oracle dot com
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-07-17 19:14 UTC (permalink / raw)
  To: gcc-bugs



-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-07-17 19:14:09
               date|                            |


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


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

* [Bug c++/44969] [C++0x] <type_traits> std::is_constructible broken for fundamental types.
  2010-07-17  0:01 [Bug libstdc++/44969] New: [C++0x] <type_traits> std::is_constructible broken for fundamental types piotr dot rak at gmail dot com
                   ` (3 preceding siblings ...)
  2010-07-17 19:14 ` paolo dot carlini at oracle dot com
@ 2010-07-17 19:14 ` paolo dot carlini at oracle dot com
  2010-07-17 20:54 ` jason at redhat dot com
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-07-17 19:14 UTC (permalink / raw)
  To: gcc-bugs

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



------- Comment #4 from paolo dot carlini at oracle dot com  2010-07-17 19:14 -------
I attached a draft which fixes the original testcase as a SFINAE issue. Seems
to me rather straightforward and consistent with existing practice in typeck.c,
just passes down complain to build_x_compound_expr_from_list. Regtests fine.

However, the reduced testcase I attached, using enable_if instead of decltype,
is not fixed by it. In that case the error, of the form:

a.cc:19:66: error: invalid use of template type parameter ‘Arg1_’
a.cc:19:66: error: invalid use of template type parameter ‘Arg2_’
a.cc:19:66: error: invalid use of template type parameter ‘Tp1’

come from cxx_incomplete_type_diagnostic, called by complete_type_or_else,
called in turn by build_functional_cast:1609, where it does:

  if (!complete_type_or_else (type, NULL_TREE))
    return error_mark_node;

irrespective of complain. Jason, should complete_type_or_else be something
different when tf_none?


-- 


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


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

* [Bug c++/44969] [C++0x] <type_traits> std::is_constructible broken for fundamental types.
  2010-07-17  0:01 [Bug libstdc++/44969] New: [C++0x] <type_traits> std::is_constructible broken for fundamental types piotr dot rak at gmail dot com
                   ` (4 preceding siblings ...)
  2010-07-17 19:14 ` paolo dot carlini at oracle dot com
@ 2010-07-17 20:54 ` jason at redhat dot com
  2010-07-17 21:10 ` paolo dot carlini at oracle dot com
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jason at redhat dot com @ 2010-07-17 20:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from jason at redhat dot com  2010-07-17 20:53 -------
Subject: Re:  [C++0x] <type_traits> std::is_constructible broken
 for fundamental types.

> irrespective of complain. Jason, should complete_type_or_else be something
> different when tf_none?

Perhaps, but we shouldn't be dealing with template parameters there 
anyway; they should have been substituted away by this point.  I'm 
investigating.

Jason


-- 


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


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

* [Bug c++/44969] [C++0x] <type_traits> std::is_constructible broken for fundamental types.
  2010-07-17  0:01 [Bug libstdc++/44969] New: [C++0x] <type_traits> std::is_constructible broken for fundamental types piotr dot rak at gmail dot com
                   ` (5 preceding siblings ...)
  2010-07-17 20:54 ` jason at redhat dot com
@ 2010-07-17 21:10 ` paolo dot carlini at oracle dot com
  2010-07-18 22:33 ` jason at redhat dot com
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-07-17 21:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from paolo dot carlini at oracle dot com  2010-07-17 21:09 -------
Great, thanks a lot.


-- 


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


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

* [Bug c++/44969] [C++0x] <type_traits> std::is_constructible broken for fundamental types.
  2010-07-17  0:01 [Bug libstdc++/44969] New: [C++0x] <type_traits> std::is_constructible broken for fundamental types piotr dot rak at gmail dot com
                   ` (6 preceding siblings ...)
  2010-07-17 21:10 ` paolo dot carlini at oracle dot com
@ 2010-07-18 22:33 ` jason at redhat dot com
  2010-07-19  9:38 ` paolo dot carlini at oracle dot com
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jason at redhat dot com @ 2010-07-18 22:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jason at redhat dot com  2010-07-18 22:33 -------
Subject: Re:  [C++0x] <type_traits> std::is_constructible broken
 for fundamental types.

On 07/17/2010 03:14 PM, paolo dot carlini at oracle dot com wrote:
> I attached a draft which fixes the original testcase as a SFINAE issue. Seems
> to me rather straightforward and consistent with existing practice in typeck.c,
> just passes down complain to build_x_compound_expr_from_list. Regtests fine.

Looks good.  I haven't tracked down the other issue yet.

Jason


-- 


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


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

* [Bug c++/44969] [C++0x] <type_traits> std::is_constructible broken for fundamental types.
  2010-07-17  0:01 [Bug libstdc++/44969] New: [C++0x] <type_traits> std::is_constructible broken for fundamental types piotr dot rak at gmail dot com
                   ` (7 preceding siblings ...)
  2010-07-18 22:33 ` jason at redhat dot com
@ 2010-07-19  9:38 ` paolo dot carlini at oracle dot com
  2010-07-19 10:28 ` paolo at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-07-19  9:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from paolo dot carlini at oracle dot com  2010-07-19 09:38 -------
OK, I'm committing my bits and leaving the PR open for you to investigate the
second issue (PS: I noticed an ICE on invalid while quickly hacking the
testcase, if I figure out isn't a duplicate I'll file a separate PR asap)


-- 


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


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

* [Bug c++/44969] [C++0x] <type_traits> std::is_constructible broken for fundamental types.
  2010-07-17  0:01 [Bug libstdc++/44969] New: [C++0x] <type_traits> std::is_constructible broken for fundamental types piotr dot rak at gmail dot com
                   ` (8 preceding siblings ...)
  2010-07-19  9:38 ` paolo dot carlini at oracle dot com
@ 2010-07-19 10:28 ` paolo at gcc dot gnu dot org
  2010-07-19 14:51 ` jason at gcc dot gnu dot org
  2010-07-20  9:29 ` paolo dot carlini at oracle dot com
  11 siblings, 0 replies; 13+ messages in thread
From: paolo at gcc dot gnu dot org @ 2010-07-19 10:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from paolo at gcc dot gnu dot org  2010-07-19 10:28 -------
Subject: Bug 44969

Author: paolo
Date: Mon Jul 19 10:27:58 2010
New Revision: 162303

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=162303
Log:
/cp
2010-07-19  Paolo Carlini  <paolo.carlini@oracle.com>

        PR c++/44969
        * typeck.c (build_x_compound_expr_from_list): Add tsubst_flags_t
        parameter.
        * cp-tree.h: Adjust declaration.
        * init.c (perform_member_init): Adjust caller.
        * decl.c (grok_reference_init, cp_finish_decl): Likewise.
        * typeck2.c (store_init_value): Likewise.
        (build_functional_cast): Pass complain argument to
        build_x_compound_expr_from_list.

/testsuite
2010-07-19  Paolo Carlini  <paolo.carlini@oracle.com>

        PR c++/44969
        * g++.dg/template/sfinae23.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/template/sfinae23.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/init.c
    trunk/gcc/cp/typeck.c
    trunk/gcc/cp/typeck2.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug c++/44969] [C++0x] <type_traits> std::is_constructible broken for fundamental types.
  2010-07-17  0:01 [Bug libstdc++/44969] New: [C++0x] <type_traits> std::is_constructible broken for fundamental types piotr dot rak at gmail dot com
                   ` (9 preceding siblings ...)
  2010-07-19 10:28 ` paolo at gcc dot gnu dot org
@ 2010-07-19 14:51 ` jason at gcc dot gnu dot org
  2010-07-20  9:29 ` paolo dot carlini at oracle dot com
  11 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-07-19 14:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from jason at gcc dot gnu dot org  2010-07-19 14:51 -------
Subject: Bug 44969

Author: jason
Date: Mon Jul 19 14:50:52 2010
New Revision: 162307

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=162307
Log:
        PR c++/44969
        * tree.c (cp_tree_equal): Compare type of *CAST_EXPR.
        * pt.c (iterative_hash_template_arg): Hash type of *CAST_EXPR.

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


-- 


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


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

* [Bug c++/44969] [C++0x] <type_traits> std::is_constructible broken for fundamental types.
  2010-07-17  0:01 [Bug libstdc++/44969] New: [C++0x] <type_traits> std::is_constructible broken for fundamental types piotr dot rak at gmail dot com
                   ` (10 preceding siblings ...)
  2010-07-19 14:51 ` jason at gcc dot gnu dot org
@ 2010-07-20  9:29 ` paolo dot carlini at oracle dot com
  11 siblings, 0 replies; 13+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-07-20  9:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from paolo dot carlini at oracle dot com  2010-07-20 09:29 -------
Fixed for 4.6.0.


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.6.0


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


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

end of thread, other threads:[~2010-07-20  9:29 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-17  0:01 [Bug libstdc++/44969] New: [C++0x] <type_traits> std::is_constructible broken for fundamental types piotr dot rak at gmail dot com
2010-07-17  0:03 ` [Bug libstdc++/44969] " piotr dot rak at gmail dot com
2010-07-17  0:56 ` paolo dot carlini at oracle dot com
2010-07-17 19:05 ` [Bug c++/44969] " paolo dot carlini at oracle dot com
2010-07-17 19:14 ` paolo dot carlini at oracle dot com
2010-07-17 19:14 ` paolo dot carlini at oracle dot com
2010-07-17 20:54 ` jason at redhat dot com
2010-07-17 21:10 ` paolo dot carlini at oracle dot com
2010-07-18 22:33 ` jason at redhat dot com
2010-07-19  9:38 ` paolo dot carlini at oracle dot com
2010-07-19 10:28 ` paolo at gcc dot gnu dot org
2010-07-19 14:51 ` jason at gcc dot gnu dot org
2010-07-20  9:29 ` paolo dot 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).