public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/65110] New: Does not accept multi-argument template in member initialization
@ 2015-02-18 19:18 stanshebs at earthlink dot net
  2015-02-18 19:30 ` [Bug c++/65110] " redi at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: stanshebs at earthlink dot net @ 2015-02-18 19:18 UTC (permalink / raw)
  To: gcc-bugs

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.


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

* [Bug c++/65110] Does not accept multi-argument template in member initialization
  2015-02-18 19:18 [Bug c++/65110] New: Does not accept multi-argument template in member initialization stanshebs at earthlink dot net
@ 2015-02-18 19:30 ` redi at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2015-02-18 19:30 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#325 and so
a dup of PR 52595

*** This bug has been marked as a duplicate of bug 52595 ***


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

end of thread, other threads:[~2015-02-18 19:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-18 19:18 [Bug c++/65110] New: Does not accept multi-argument template in member initialization stanshebs at earthlink dot net
2015-02-18 19:30 ` [Bug c++/65110] " redi at gcc dot gnu.org

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