public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "guille at cal dot berkeley.edu" <gcc-bugzilla@gcc.gnu.org> 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 [thread overview] Message-ID: <bug-67910-4-kJJaxa71oH@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-67910-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67910 --- Comment #5 from Guille <guille at cal dot berkeley.edu> --- (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 ‘int main()’: t.c:10:12: error: conversion from ‘B’ to non-scalar type ‘A’ requested A a = f(B()); ^ t.c: In instantiation of ‘auto:1 f(auto:1) [with auto:1 = B]’: t.c:10:16: required from here t.c:6:39: error: could not convert ‘A()’ from ‘A’ to ‘B’ 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: <gcc-bugs-return-499172-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org> 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: <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 3720 invoked by uid 48); 9 Oct 2015 21:32:38 -0000 From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.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: <bug-67913-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-10/txt/msg00727.txt.bz2 Content-length: 1181 https://gcc.gnu.org/bugzilla/show_bug.cgi?idg913 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.
next prev parent reply other threads:[~2015-10-09 19:44 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-10-09 16:46 [Bug c++/67910] New: " guille at cal dot berkeley.edu 2015-10-09 16:48 ` [Bug c++/67910] " guille at cal dot berkeley.edu 2015-10-09 16:50 ` guille at cal dot berkeley.edu 2015-10-09 16:51 ` guille at cal dot berkeley.edu 2015-10-09 17:17 ` glisse at gcc dot gnu.org 2015-10-09 19:44 ` guille at cal dot berkeley.edu [this message] 2015-10-10 5:39 ` guille at cal dot berkeley.edu 2015-10-10 5:41 ` guille at cal dot berkeley.edu
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-67910-4-kJJaxa71oH@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: linkBe 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).