From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1423 invoked by alias); 13 Feb 2002 06:26:03 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 1379 invoked by uid 71); 13 Feb 2002 06:26:01 -0000 Resent-Date: 13 Feb 2002 06:26:01 -0000 Resent-Message-ID: <20020213062601.1378.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, ac131313@redhat.com Received:(qmail 27898 invoked by uid 61); 13 Feb 2002 06:20:42 -0000 Message-Id:<20020213062042.27897.qmail@sources.redhat.com> Date: Tue, 12 Feb 2002 22:26:00 -0000 From: ac131313@redhat.com Reply-To: ac131313@redhat.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c/5678: Returning a void in a void func doesn't get a warning X-SW-Source: 2002-02/txt/msg00303.txt.bz2 List-Id: >Number: 5678 >Category: c >Synopsis: Returning a void in a void func doesn't get a warning >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Tue Feb 12 22:26:00 PST 2002 >Closed-Date: >Last-Modified: >Originator: Andrew Cagney >Release: unknown-1.0 >Organization: >Environment: N/A >Description: [added gcc] Checked in as obvious. Wonder why GCC didn't warn about this. Should we add some more -Wxxx flags? I was looking at it and wondering the same thing - I know I've fixed botched return type warnings. Trying: static int f1 (void) { return 1; } static void f2 (void) { return 1; } static void f3 (void) { return; } static int f4 (void) { return; } I get: -Wimplicit -Wreturn-type -Wcomment -Wtrigraphs -Wformat -Wparentheses -Wpointer-arith -Wuninitialized -Werror doublest.c: In function `f2': doublest.c:741: warning: `return' with a value, in function returning void doublest.c: In function `f4': doublest.c:743: warning: `return' with no value, in function returning non-void so ok so far. Hmm, I think this tells the story: static void f5 (int a) { return f3(); } Returning the result from a function that returns void (f3()) doesn't attract a warning. Bug or feature? Andrew -- Further discussion concluded it wasn't compliant with ISO C or C99. It might fall into GCC feature category. I struggle to see advantages in this. >How-To-Repeat: >Fix: >Release-Note: >Audit-Trail: >Unformatted: