Bug 46158 - Spurious never executed warning
Summary: Spurious never executed warning
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.2.1
: P3 normal
Target Milestone: 4.5.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-24 19:54 UTC by William K Foster
Modified: 2010-10-25 21:02 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description William K Foster 2010-10-24 19:54:01 UTC
// test.cpp

#define testIt(expression)						\
{									\
  if (expression) {							\
      throw true;							\
  }									\
}

void
useIt()
{
  bool eof = false;

  testIt(eof)
}

// End of test.cpp

--------------------------------------------

gcc --version; gcc -Werror -Wunreachable-code -o test.o test.cpp

--------------------------------------------

gcc (GCC) 4.2.1 20070719  [FreeBSD]
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

cc1plus: warnings being treated as errors
test.cpp: In function 'void useIt()':
test.cpp:15: warning: will never be executed
Comment 1 William K Foster 2010-10-24 19:59:23 UTC
Also, in a much more complicated test case (not provided) I get a much more obtuse warning message that does not refer me to my file, but instead a header:

/usr/include/c++/4.2/bits/allocator.h: In copy constructor 'std::allocator<_Alloc>::allocator(const std::allocator<_Alloc>&) [with _Tp = char]':
/usr/include/c++/4.2/bits/allocator.h:103: warning: will never be executed
/usr/include/c++/4.2/bits/allocator.h:102: warning: will never be executed
/usr/include/c++/4.2/ext/new_allocator.h: In copy constructor '__gnu_cxx::new_allocator<_Tp>::new_allocator(const __gnu_cxx::new_allocator<_Tp>&) [with _Tp = char]':
/usr/include/c++/4.2/ext/new_allocator.h:70: warning: will never be executed
/usr/include/c++/4.2/bits/allocator.h: In destructor 'std::allocator<_Alloc>::~allocator() [with _Tp = char]':
/usr/include/c++/4.2/bits/allocator.h:108: warning: will never be executed
/usr/include/c++/4.2/ext/new_allocator.h: In destructor '__gnu_cxx::new_allocator<_Tp>::~new_allocator() [with _Tp = char]':
/usr/include/c++/4.2/ext/new_allocator.h:75: warning: will never be executed
/usr/include/c++/4.2/bits/allocator.h: In destructor 'std::allocator<_Alloc>::~allocator() [with _Tp = char]':
/usr/include/c++/4.2/bits/allocator.h:108: warning: will never be executed
gmake: *** [ARCH.freebsd_61_i86/debug/opFlume_delta.o] Error 1
Comment 2 Andrew Pinski 2010-10-25 21:01:51 UTC
-Wunreachable-code is broken and has been removed from GCC 4.5.  Do not use it.