Bug 44106 - False warning: 'control reaches end of non-void function' when comparing to undefined var
Summary: False warning: 'control reaches end of non-void function' when comparing to u...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.6.0
: P3 minor
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2010-05-13 04:56 UTC by Jeff Donner
Modified: 2010-08-23 07:23 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.3.2 4.1.2 4.3.2
Last reconfirmed: 2010-07-24 21:26:19


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jeff Donner 2010-05-13 04:56:41 UTC
int f(int i)
{
   if (i == undefined_var) {
      return 1;
   }
   else {
      return 0;
   }
}

/usr/local/gcc-svn/bin/g++ -Wall -Wextra -c bad-return.cpp
bad-return.cpp: In function ‘int f(int)’:
bad-return.cpp:3:13: error: ‘undefined_var’ was not declared in this scope
bad-return.cpp:9:1: warning: control reaches end of non-void function [-Wreturn-type]

Happens as .c and gcc, and as .cpp with g++. The warning does not occur in 4.4.3. Untried with 4.5.x.
Comment 1 Jeff Donner 2010-05-14 02:23:03 UTC
Occurs in GCC 4.5.1 also. 
Comment 2 Andrew Pinski 2010-07-24 21:26:19 UTC
>The warning does not occur in 4.4.3.

For C, it does.  And it warns in 4.1.2 also.

Confirmed.