public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mbianco at cscs dot ch" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/65133] New: [C++11] Result type deduction proceeds even though argument deduction fails
Date: Fri, 20 Feb 2015 09:18:00 -0000 [thread overview]
Message-ID: <bug-65133-4@http.gcc.gnu.org/bugzilla/> (raw)
[-- 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?
next reply other threads:[~2015-02-20 9:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-20 9:18 mbianco at cscs dot ch [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-65133-4@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).