public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/65133] New: [C++11] Result type deduction proceeds even though argument deduction fails
@ 2015-02-20  9:18 mbianco at cscs dot ch
  2015-03-04 11:19 ` [Bug c++/65133] " redi at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: mbianco at cscs dot ch @ 2015-02-20  9:18 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 6092 bytes --]

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65133

            Bug ID: 65133
           Summary: [C++11] Result type deduction proceeds even though
                    argument deduction fails
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mbianco at cscs dot ch

GCC 4.8.0 to 4.9.0 fails in employing SFINAE to find the proper implementation
when infinite template recursion is hit. ICPC (15) and CLANG++ (3.7) compile
and run the code correctly.


#STANDALONE SOURCE

#include <iostream>
#include <type_traits>

template <int I>
struct count
{
    using type = typename count<I-1>::type;
};

template <>
struct count<0>
{
    using type = void;
};


template <int I>
auto foo(typename std::enable_if<(I>=0)>::type * = nullptr) -> typename
count<I>::type
/* Substituting count<I>::type with void would make the code to compile.*/
{
    std::cout << "I>=0" << std::endl;
}


// Specialization #2
template <int I>
void foo(typename std::enable_if<(I<0)>::type * = nullptr)
{
    std::cout << "I<0" << std::endl;
}

int main() {

    foo<2>(); // This Works fine
    foo<-1>(); // This should go the specialization #2 but GCC fails since it
goes into counting down 900 times without resolution

    return 0;
}

### COMPILER INVOCATION:
g++ -std=c++11 -c main.cpp


### EXPECTED OUTPUT:
Successful compile.


### ACTUAL OUTPUT:
main.cpp:7:43: error: template instantiation depth exceeds maximum of 900 (use
-ftemplate-depth= to increase the maximum) instantiating ‘struct count<-900>’
     using type = typename count<I-1>::type;
                                           ^
main.cpp:7:43:   recursively required from ‘struct count<-2>’
main.cpp:7:43:   required from ‘struct count<-1>’
main.cpp:18:6:   required by substitution of ‘template<int I> typename
count<I>::type foo(typename std::enable_if<(I >= 0)>::type*) [with int I = -1]’
main.cpp:35:13:   required from here

main.cpp:7:43: error: invalid use of incomplete type ‘struct count<-900>’
main.cpp:5:8: error: declaration of ‘struct count<-900>’
 struct count
        ^

### g++ -v OUTPUT:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/apps/dom/gcc/4.9.0/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --prefix=/apps/dom/gcc/4.9.0
--enable-languages=c,c++,fortran --with-mpfr=/apps/dom/gnu/mpfr/3.1.2
--with-mpc=/apps/dom/gnu/mpc/1.0.2 --with-gmp=/apps/dom/gnu/gmp/5.1.3
--with-isl=/apps/dom/gnu/isl/0.12.2 --with-cloog=/apps/dom/gnu/cloog/0.18.1
Thread model: posix
gcc version 4.9.0 (GCC)
>From gcc-bugs-return-477892-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Feb 20 09:21:05 2015
Return-Path: <gcc-bugs-return-477892-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 15493 invoked by alias); 20 Feb 2015 09:21:04 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 15205 invoked by uid 48); 20 Feb 2015 09:21:00 -0000
From: "e29253 at jp dot ibm.com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug go/65134] New: gccgo ignores the attribute "constructor" in a subdirectory
Date: Fri, 20 Feb 2015 09:21:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: go
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: e29253 at jp dot ibm.com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: ian at airs dot com
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc attachments.created
Message-ID: <bug-65134-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-02/txt/msg02225.txt.bz2
Content-length: 1462

https://gcc.gnu.org/bugzilla/show_bug.cgi?ide134

            Bug ID: 65134
           Summary: gccgo ignores the attribute "constructor" in a
                    subdirectory
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: go
          Assignee: ian at airs dot com
          Reporter: e29253 at jp dot ibm.com
                CC: cmang at google dot com

Created attachment 34813
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id4813&actioníit
Example to reproduce the constructor problem

Gccgo ignores a C-function with the "constructor" attribute in a subdirectory.
In the attached example, gc executes a C-function init() in sub.go before a Go
function main(), but gccgo does not:

~/example$ export GOPATH=$(pwd)
~/example$ /usr/local/go/bin/go version
go version go1.4.2 linux/amd64
~/example$ /usr/local/go/bin/go run src/main/main.go
Hello from constructor
Hello from main

~/example$ export LD_LIBRARY_PATH=/usr/local/gccgo/lib64:$LD_LIBRARY_PATH
~/example$ /usr/local/gccgo/bin/go version
go version gccgo (GCC) 5.0.0 20150115 (experimental) linux/amd64
~/example$ /usr/local/gccgo/bin/go run src/main/main.go
Hello from main

~/example$

It seems this difference is due to that gccgo cannot detect a function with the
constructor attribute in an archived objects created in a subdirectory. Is
there any workaround to avoid this problem?


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

* [Bug c++/65133] [C++11] Result type deduction proceeds even though argument deduction fails
  2015-02-20  9:18 [Bug c++/65133] New: [C++11] Result type deduction proceeds even though argument deduction fails mbianco at cscs dot ch
@ 2015-03-04 11:19 ` redi at gcc dot gnu.org
  2015-05-12  8:51 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2015-03-04 11:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65133

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |5.0
      Known to fail|                            |4.8.3, 4.9.1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This compiles OK with trunk, not sure if we want to keep it open.


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

* [Bug c++/65133] [C++11] Result type deduction proceeds even though argument deduction fails
  2015-02-20  9:18 [Bug c++/65133] New: [C++11] Result type deduction proceeds even though argument deduction fails mbianco at cscs dot ch
  2015-03-04 11:19 ` [Bug c++/65133] " redi at gcc dot gnu.org
@ 2015-05-12  8:51 ` paolo.carlini at oracle dot com
  2015-05-12  9:03 ` paolo at gcc dot gnu.org
  2015-05-12  9:04 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2015-05-12  8:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65133

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Confirmed fixed for 5.1.0. I'm adding a testcase and closing the bug.


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

* [Bug c++/65133] [C++11] Result type deduction proceeds even though argument deduction fails
  2015-02-20  9:18 [Bug c++/65133] New: [C++11] Result type deduction proceeds even though argument deduction fails mbianco at cscs dot ch
  2015-03-04 11:19 ` [Bug c++/65133] " redi at gcc dot gnu.org
  2015-05-12  8:51 ` paolo.carlini at oracle dot com
@ 2015-05-12  9:03 ` paolo at gcc dot gnu.org
  2015-05-12  9:04 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: paolo at gcc dot gnu.org @ 2015-05-12  9:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65133

--- Comment #3 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> ---
Author: paolo
Date: Tue May 12 09:03:04 2015
New Revision: 223047

URL: https://gcc.gnu.org/viewcvs?rev=223047&root=gcc&view=rev
Log:
2015-05-12  Paolo Carlini  <paolo.carlini@oracle.com>

        PR c++/65133
        * g++.dg/cpp0x/trailing10.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/trailing10.C
Modified:
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/65133] [C++11] Result type deduction proceeds even though argument deduction fails
  2015-02-20  9:18 [Bug c++/65133] New: [C++11] Result type deduction proceeds even though argument deduction fails mbianco at cscs dot ch
                   ` (2 preceding siblings ...)
  2015-05-12  9:03 ` paolo at gcc dot gnu.org
@ 2015-05-12  9:04 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2015-05-12  9:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65133

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |5.0

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


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

end of thread, other threads:[~2015-05-12  9:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-20  9:18 [Bug c++/65133] New: [C++11] Result type deduction proceeds even though argument deduction fails mbianco at cscs dot ch
2015-03-04 11:19 ` [Bug c++/65133] " redi at gcc dot gnu.org
2015-05-12  8:51 ` paolo.carlini at oracle dot com
2015-05-12  9:03 ` paolo at gcc dot gnu.org
2015-05-12  9:04 ` 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).