This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug optimization/13000] New: Using -Ox cannot detect missing return statement in a function
- From: "cheng at powertv dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Nov 2003 23:07:12 -0000
- Subject: [Bug optimization/13000] New: Using -Ox cannot detect missing return statement in a function
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
In the following contrived code snippet, gcc 2.953 will not complain about the
function not returning a value despite its function signature says so when
compiling with optimizations enabled (e.g. -O1 or -O2). Disabling
optimizations with -O0 will enable the compiler to display an appropriate error
message. This problem appears in both C and C++ test code.
typedef int ui32;
static ui32 AddPrimitiveDvrResource(ui32 hSession, ui32 *pSessNode,
void *pvResourceDescriptor, ui32 dwSize);
static ui32 AddPrimitiveDvrResource(ui32 hSession, ui32 *pSessNode,
void *pvResourceDescriptor, ui32 dwSize)
{
ui32 rc;
if (dwSize != 32)
{
rc = 0;
}
else
{
// set the DVR ID in the session node even if subsequent steps
fail
if (dwSize)
{
rc = dwSize;
}
else
{
if (!pSessNode)
{
rc = 2;
}
else
{
ui32 dwTranscryptorAvrID = 0;
if (rc = dwTranscryptorAvrID)
{
dwTranscryptorAvrID;
}
else
{
ui32 dk;
if (rc = 16)
{
dk = rc;
}
else
{
if (dk)
{
rc = 1;
}
else
{
rc = 0;
}
}
}
}
}
}
}
int main(int argc, char **argv)
{
int result = AddPrimitiveDvrResource(0,0,0,0);
return 0;
}
--
Summary: Using -Ox cannot detect missing return statement in a
function
Product: gcc
Version: 2.95.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: cheng at powertv dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13000