From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15028 invoked by alias); 16 Nov 2005 01:05:56 -0000 Received: (qmail 14943 invoked by uid 22791); 16 Nov 2005 01:05:52 -0000 Received: from qnxmail.qnx.com (HELO nimbus.ott.qnx.com) (209.226.137.76) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Wed, 16 Nov 2005 01:05:52 +0000 Received: by nimbus.ott.qnx.com with Internet Mail Service (5.5.2653.19) id ; Tue, 15 Nov 2005 20:05:51 -0500 Message-ID: <3518719F06577C4F85DA618E3C37AB9101389221@nimbus.ott.qnx.com> From: Ryan Mansfield To: 'Pierre Sarrazin' , gcc-help@gcc.gnu.org Subject: RE: Control reaches end of non-void function: why only a warning? Date: Wed, 16 Nov 2005 01:05:00 -0000 MIME-Version: 1.0 Content-Type: text/plain Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2005-11/txt/msg00236.txt.bz2 > Not a bad idea, but in many situations, I am compiling a large > project whose code generates many warnings, and turning them all > into errors would be unworkable. Use -Werror with only the specific warning option (-Wreturn-type) turned on. Fix the warnings, remove -Werror and add back in the other warning options. > I have patched my copy of the gcc sources to turn this warning > into an error, but I'm still curious to see an example of when it > is useful to knowingly allow the control flow to leave a function > with an undefined return value. There could be a function with a control flow that returns something useful in one path and something meaningless in another. Or a function calls another function that never returns (exit example). It is more important for a compiler to follow the language standard and accept valid source than it is to have a compiler that tries to enforce good programming practises and design. There are plenty of static analysis tools for checking c programs available (lint/splint/etc). Regards, Ryan Mansfield