From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 77635 invoked by alias); 9 Oct 2015 19:44:26 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 77593 invoked by uid 48); 9 Oct 2015 19:44:22 -0000 From: "guille at cal dot berkeley.edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/67910] Two autos in a single function confuses the type system Date: Fri, 09 Oct 2015 19:44:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 5.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: guille at cal dot berkeley.edu X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-10/txt/msg00726.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D67910 --- Comment #5 from Guille --- (In reply to Marc Glisse from comment #4) > This seems to be already fixed on trunk. Just tested on most recent gcc version 5.2.1 20151006 (GCC) and it doesn't compile: t.c: In function =E2=80=98int main()=E2=80=99: t.c:10:12: error: conversion from =E2=80=98B=E2=80=99 to non-scalar type = =E2=80=98A=E2=80=99 requested A a =3D f(B()); ^ t.c: In instantiation of =E2=80=98auto:1 f(auto:1) [with auto:1 =3D B]=E2= =80=99: t.c:10:16: required from here t.c:6:39: error: could not convert =E2=80=98A()=E2=80=99 from =E2=80=98A=E2= =80=99 to =E2=80=98B=E2=80=99 static auto f(auto b) -> A { return A(); } ^ >>From gcc-bugs-return-499172-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Oct 09 21:32:42 2015 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 3760 invoked by alias); 9 Oct 2015 21:32:42 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 3720 invoked by uid 48); 9 Oct 2015 21:32:38 -0000 From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/67913] New: new expression with negative size not diagnosed Date: Fri, 09 Oct 2015 21:32:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 6.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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 target_milestone Message-ID: 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-10/txt/msg00727.txt.bz2 Content-length: 1181 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67913 Bug ID: 67913 Summary: new expression with negative size not diagnosed Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- A new expression is considered erroneous if the expression in its noptr-new-declarator is of non-class type and its value before converting to std::size_t is less than zero. If the expression is a constant expression, the program is ill-fomed. The following program contains two such ill-formed expressions is not diagnosed by GCC. void* operator new[] (unsigned long, void *p) { return p; } void foo (void) { char c; new char [-1]; new (&c) char [-1]; } Clang issues the following warnings for it: a.cpp:6:15: warning: array size is negative [-Wbad-array-new-length] new char [-1]; ^~ a.cpp:7:20: warning: array size is negative [-Wbad-array-new-length] new (&c) char [-1]; ^~ 2 warnings generated.