Compiler Warning Only in Release

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

Post Reply
Active Poster
Active Poster
Posts: 10
Joined: Tue Dec 17, 2019 12:41 am

Compiler Warning Only in Release

Post by d7d1cd »

Welcome all. Wrote the following test code:

Code: Select all

/*----- unit1.h -----*/
inline bool Foo();
/*----- unit1.cpp -----*/
bool TForm1::Foo()
  int b;
  int i;
  if (b == 7) i = 1;
  else if (b == 8) i = 2;
  else return true;
  return false;
Compilation of this code in Debug mode is successful. In Release mode, a warning appears that the function should return a value ([bcc32 Warning] Unit1.cpp (32): W8070 Function should return a value).
If you remove the inline keyword, the warning disappears. It also disappears if line 13 is replaced with this code:

Code: Select all

  else i = 3;
  if (i == 3) return true;
Can you explain why the warning appears? Moreover, it appears only in the "classic" compiler. In Clang, this is not observed.
BCBJ Author
BCBJ Author
Posts: 1726
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA

Re: Compiler Warning Only in Release

Post by rlebeau »

d7d1cd wrote:Welcome all. Wrote the following test code:
Why are you marking a class method as 'inline' when its implementation is in another file? The compiler won't be able to inline such code, so why even try?
Remy Lebeau (TeamB)
Lebeau Software
Post Reply