public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/67730] New: [5.2 Regression] No warning when returning NULL in void function
@ 2015-09-27 11:19 damwdan at gmail dot com
  2015-09-28 11:04 ` [Bug c/67730] [5/6 " rguenth at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: damwdan at gmail dot com @ 2015-09-27 11:19 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 67730
           Summary: [5.2 Regression] No warning when returning NULL in
                    void function
           Product: gcc
           Version: 5.2.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: damwdan at gmail dot com
  Target Milestone: ---

Created attachment 36401
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36401&action=edit
preprocessed source file

Following up on this Stackoverflow post:
http://stackoverflow.com/q/32732281/5366270

There seems to be a regression in gcc 5.2.0. When returning NULL in a void
function, gcc *does not* warn or error. gcc 4.9.2 (and some other previous
versions, as mentioned in the post) warns. clang 3.7 errors. As noted by "Marc
Glisse", using -Wsystem-headers does the trick and generates a warning. Though,
the preprocessed output (attached) is exactly the same.

$ cat c.c
#include <stddef.h>

void procedure(void)
{
    return NULL;
}
$ gcc -Wall -Wextra -std=c99 -pedantic -c c.c
$ gcc -Wall -Wextra -std=c99 -pedantic -Wsystem-headers -c c.c
In file included from c.c:1:0:
c.c: In function ‘procedure’:
c.c:5:12: warning: ‘return’ with a value, in function returning void
     return NULL;
            ^
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /build/gcc-multilib/src/gcc-5.2.0/configure --prefix=/usr
--libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared
--enable-threads=posix --enable-libmpx --with-system-zlib --with-isl
--enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu
--disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object
--enable-linker-build-id --enable-lto --enable-plugin
--enable-install-libiberty --with-linker-hash-style=gnu
--enable-gnu-indirect-function --enable-multilib --disable-werror
--enable-checking=release --with-default-libstdcxx-abi=gcc4-compatible
Thread model: posix
gcc version 5.2.0 (GCC) 

Note that the bug also appears when returning NULL in an int or char function,
but not double (an error is generated).
>From gcc-bugs-return-498129-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun Sep 27 11:41:13 2015
Return-Path: <gcc-bugs-return-498129-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 35685 invoked by alias); 27 Sep 2015 11:41:12 -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 35654 invoked by uid 48); 27 Sep 2015 11:41:09 -0000
From: "kkojima at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/67391] [SH] Convert clrt addc to normal add insn
Date: Sun, 27 Sep 2015 11:41:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: unknown
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: kkojima 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:
Message-ID: <bug-67391-4-28kWHu6pzr@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-67391-4@http.gcc.gnu.org/bugzilla/>
References: <bug-67391-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-09/txt/msg02107.txt.bz2
Content-length: 337

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

--- Comment #25 from Kazumoto Kojima <kkojima at gcc dot gnu.org> ---
(In reply to Oleg Endo from comment #24)
> Could you please re-run that test with attachment 36400 [details]?

Yes, 36400 fixes that failure:
PASS: gcc.c-torture/compile/sync-3.c   -O1   (test for warnings, line )


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

end of thread, other threads:[~2015-10-05 12:37 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-27 11:19 [Bug c/67730] New: [5.2 Regression] No warning when returning NULL in void function damwdan at gmail dot com
2015-09-28 11:04 ` [Bug c/67730] [5/6 " rguenth at gcc dot gnu.org
2015-09-28 17:07 ` joseph at codesourcery dot com
2015-09-28 18:14 ` manu at gcc dot gnu.org
2015-09-28 18:29 ` manu at gcc dot gnu.org
2015-09-29 14:24 ` mpolacek at gcc dot gnu.org
2015-09-30 11:27 ` mpolacek at gcc dot gnu.org
2015-09-30 12:21 ` mpolacek at gcc dot gnu.org
2015-10-02 18:02 ` mpolacek at gcc dot gnu.org
2015-10-05 12:35 ` [Bug c/67730] [5 " mpolacek at gcc dot gnu.org
2015-10-05 12:37 ` mpolacek 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).