public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "stanshebs at earthlink dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/65110] New: Does not accept multi-argument template in member initialization
Date: Wed, 18 Feb 2015 19:18:00 -0000	[thread overview]
Message-ID: <bug-65110-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 65110
           Summary: Does not accept multi-argument template in member
                    initialization
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stanshebs at earthlink dot net

The following snippet generates a host of complaints, presumably connected to
ambiguity of template argument list vs initializer list:

template<typename, typename> struct C { int n; };
struct D { int k = C<D, D>().n; };

$ cc -Wall -std=c++11 demo.cc
demo.cc:2:25: error: expected ‘;’ at end of member declaration
 struct D { int k = C<D, D>().n; };
                         ^
demo.cc:2:26: error: expected unqualified-id before ‘>’ token
 struct D { int k = C<D, D>().n; };
                          ^
demo.cc:2:22: error: wrong number of template arguments (1, should be 2)
 struct D { int k = C<D, D>().n; };
                      ^
demo.cc:1:37: error: provided for ‘template<class, class> struct C’
 template<typename, typename> struct C { int n; };
                                     ^

This occurs for both 4.8 and current trunk; current Clang accepts without any
complaints.

(Google ref: b/19213572)
>From gcc-bugs-return-477705-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Feb 18 19:29:27 2015
Return-Path: <gcc-bugs-return-477705-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 849 invoked by alias); 18 Feb 2015 19:29:26 -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 788 invoked by uid 48); 18 Feb 2015 19:29:23 -0000
From: "froydnj at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/65111] New: null checks on pointers created from references not optimized away
Date: Wed, 18 Feb 2015 19:29:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: middle-end
X-Bugzilla-Version: unknown
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: froydnj at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter
Message-ID: <bug-65111-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/msg02038.txt.bz2
Content-length: 904

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

            Bug ID: 65111
           Summary: null checks on pointers created from references not
                    optimized away
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: froydnj at gcc dot gnu.org

Compiling the C++ code:

#include <new>

void init(int& p)
{
  new (&p) float(3.14f);
}

yields (GCC 4.9.1):

_Z4initRi:
    testq    %rdi, %rdi
    je    .L1
    movl    $0x4048f5c3, (%rdi)
.L1:
    rep ret

Compiling the equivalent code with clang (3.5 and 3.6-prerelease) yields:

_Z4initRi:                              # @_Z4initRi
    movl    $1078523331, (%rdi)     # imm = 0x4048F5C3
    retq

because clang has determined that &p cannot be null.


             reply	other threads:[~2015-02-18 19:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-18 19:18 stanshebs at earthlink dot net [this message]
2015-02-18 19:30 ` [Bug c++/65110] " redi 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-65110-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).