pyscripter 833 Posted 9 hours ago (edited) The following gives a hint in D13: H2077 Value assigned to Test never used: function Test(Value: Integer): Integer; begin Result := -1; if Value > 0 then Result := 0 else Assert(False); end; Is the hint justified? What if Assertions are turned off? Note that in earlier versions you would get a warning if you omit the first line. Edited 9 hours ago by pyscripter Share this post Link to post
Dave Nottage 631 Posted 9 hours ago 2 minutes ago, pyscripter said: The following gives a hint in D13: H2077 Value assigned to Test never used: Not for me. 4 minutes ago, pyscripter said: What if Assertions are turned off? Did you try it with assertions turned off? Share this post Link to post
pyscripter 833 Posted 9 hours ago 2 minutes ago, Dave Nottage said: Not for me. It does not produce a hint when you target x86, but it does when you target x64. Share this post Link to post
Dave Nottage 631 Posted 9 hours ago (edited) 3 minutes ago, pyscripter said: It does not produce a hint when you target x86, but it does when you target x64. Still does not for me. EDIT: Are you using the 64-bit IDE? Edited 9 hours ago by Dave Nottage Share this post Link to post
Uwe Raabe 2185 Posted 9 hours ago I made some tests. In all cases Hints are enabled. Targets: Win32/Win64 DEBUG, Assertions on : no hint DEBUG, Assertions off : no hint RELEASE, Assertions on : hint RELEASE, Assertions off : No hint The behavior with RELEASE seems fine, but why is it different with DEBUG? Share this post Link to post
pyscripter 833 Posted 9 hours ago (edited) Actually I am getting the hint with both Win32/Win64 (32 bit IDE) and a DEBUG configuration that looks like a release configuration. The funny thing is that if I remove the offending line and disable assertions, then I get a warning about the undefined result! You can't win. Edited 9 hours ago by pyscripter Share this post Link to post
Uwe Raabe 2185 Posted 9 hours ago 3 minutes ago, pyscripter said: Actually I am getting the hint with both Win32/Win64 (32 bit IDE) and a DEBUG configuration. As I am getting just the opposite, there must be some difference with our tests. Share this post Link to post
Dave Nottage 631 Posted 9 hours ago 12 minutes ago, Uwe Raabe said: The behavior with RELEASE seems fine, but why is it different with DEBUG? Looks like the Optimization switch (off) kills the hint 1 Share this post Link to post
pyscripter 833 Posted 9 hours ago (edited) The following correctly produces the same hint, whilst in some earlier Delphi versions it wrongly produced a hint if the offending statement was omitted. function Test(Value: Integer): Integer; begin Result := -1; if Value > 0 then Result := 0 else Abort; end; Edited 9 hours ago by pyscripter Share this post Link to post
Remy Lebeau 1653 Posted 4 hours ago 4 hours ago, pyscripter said: The following correctly produces the same hint Did they update Abort() to mark it with the new 'noreturn' attribute? Share this post Link to post
pyscripter 833 Posted 3 hours ago 1 hour ago, Remy Lebeau said: Did they update Abort() to mark it with the new 'noreturn' attribute? Indeed. Share this post Link to post
Remy Lebeau 1653 Posted 3 hours ago 22 minutes ago, pyscripter said: Indeed. Well, then the hint is valid since the value -1 will never be used. 1 Share this post Link to post