public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ptomulik at meil dot pw.edu.pl" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/65091] New: decltype(~arg) fails for template functions
Date: Tue, 17 Feb 2015 15:29:00 -0000	[thread overview]
Message-ID: <bug-65091-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 65091
           Summary: decltype(~arg) fails for template functions
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ptomulik at meil dot pw.edu.pl

Created attachment 34790
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34790&action=edit
ii file generated by -save-temps

The following program does not compile with g++ (although it compiles with
clang++):

template<typename T>
auto foo(T x) -> decltype(~x)
{ return ~x; }

int bar()
{ return foo(10); }

ptomulik@tea:$ g++ -std=c++11 -g -O0 -Wall -Wextra -Werror -pedantic -c -o
test.o test.cpp
test.cpp: In function ‘int bar()’:
test.cpp:6:16: error: no matching function for call to ‘foo(int)’
 { return foo(10); }
                ^
test.cpp:6:16: note: candidate is:
test.cpp:2:6: note: template<class T> decltype (~ x) foo(T)
 auto foo(T x) -> decltype(~x)
      ^
test.cpp:2:6: note:   template argument deduction/substitution failed:
test.cpp: In substitution of ‘template<class T> decltype (~ x) foo(T) [with T =
int]’:
test.cpp:6:16:   required from here
test.cpp:2:6: error: ‘x’ was not declared in this scope
test.cpp:6:19: error: control reaches end of non-void function
[-Werror=return-type]
 { return foo(10); }
                   ^
cc1plus: all warnings being treated as errors


This is specific to the unary operator "~" and expression involving argument
name (not its type). All the following variants compile well for instance:

template<typename T>
auto foo(T x) -> decltype(!x)
{ return !x; }

template<typename T>
auto foo(T x) -> decltype(-x)
{ return -x; }

template<typename T>
auto foo(T x) -> decltype(+x)
{ return +x; }

template<typename T>
auto foo(T x) -> decltype(~T())
{ return ~x; }

My gcc is:

ptomulik@tea:$ g++ --version
g++-4.9.real (Debian 4.9.2-10) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

My OS is Debian 8.0.
>From gcc-bugs-return-477573-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Feb 17 15:34:14 2015
Return-Path: <gcc-bugs-return-477573-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 31362 invoked by alias); 17 Feb 2015 15:34:13 -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 31317 invoked by uid 48); 17 Feb 2015 15:34:10 -0000
From: "howarth at bromo dot med.uc.edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/65084] Lack of type narrowing/widening inhibits good vectorization
Date: Tue, 17 Feb 2015 15:34:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: tree-optimization
X-Bugzilla-Version: unknown
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: howarth at bromo dot med.uc.edu
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: cc
Message-ID: <bug-65084-4-sW0X0TCbPG@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-65084-4@http.gcc.gnu.org/bugzilla/>
References: <bug-65084-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/msg01906.txt.bz2
Content-length: 446

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

howarth at bromo dot med.uc.edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |howarth at bromo dot med.uc.edu

--- Comment #3 from howarth at bromo dot med.uc.edu ---
I assume that https://gcc.gnu.org/bugzilla/show_bug.cgi?ide088 is a
duplicate?


             reply	other threads:[~2015-02-17 15:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-17 15:29 ptomulik at meil dot pw.edu.pl [this message]
2015-02-18 10:07 ` [Bug c++/65091] " redi at gcc dot gnu.org
2015-04-09 10:02 ` mpolacek at gcc dot gnu.org
2015-06-11  0:08 ` paolo.carlini at oracle dot com
2015-07-11 19:52 ` paolo.carlini at oracle dot com
2015-07-14 21:01 ` paolo.carlini at oracle dot com
2015-07-20 20:02 ` paolo.carlini at oracle dot com
2020-04-02 17:28 ` jakub at gcc dot gnu.org

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