Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pipecom on 3.9x verions of QB64
#12
The problem is these two lines in the code:

Code: (Select All)
While ReadFile(hStdOutPipeRead, _Offset(buf), 4096, _Offset(dwRead), 0) <> 0 And dwRead > 0
' ...
While ReadFile(hStdReadPipeError, _Offset(buf), 4096, _Offset(dwRead), 0) <> 0 And dwRead > 0

The issue is that `And` does not require the left side to be evaluated first, rather the compiler picks the order it wants to evaluate the operands in. In this case that creates a bug because the right side of the `And` depends on the result from the left side (since it assigns `dwRead`). In v3.9.0 there is a new MinGW version and it apparently decides to evaluate the `dwRead > 0` side first, resulting in the check always failing since `dwRead` starts as zero.

I'm not really sure if this is a QB64 bug or not, this is definitely something that could always happen in every QB64 version and pipecom was just getting lucky. That said this behavior probably wasn't intentional and mostly just comes from the C behavior - in C the bitwsie operators do not imply evaluation ordering like the logical operators do. A good thing to know is if in QB45 the bitwise operators did imply evaluation order and QB64 isn't doing that, or if this kind of thing could always happen. I suspect they probably did by accident since I doubt QB45 did much in the way of optimization.
Reply


Messages In This Thread
pipecom on 3.9x verions of QB64 - by krovit - 11-14-2023, 08:10 PM
RE: pipecom on 3.9x verions of QB64 - by bplus - 11-14-2023, 08:43 PM
RE: pipecom on 3.9x verions of QB64 - by bplus - 11-14-2023, 08:46 PM
RE: pipecom on 3.9x verions of QB64 - by bplus - 11-14-2023, 08:54 PM
RE: pipecom on 3.9x verions of QB64 - by a740g - 11-14-2023, 09:24 PM
RE: pipecom on 3.9x verions of QB64 - by DSMan195276 - 11-14-2023, 09:40 PM
RE: pipecom on 3.9x verions of QB64 - by SMcNeill - 11-14-2023, 09:51 PM
RE: pipecom on 3.9x verions of QB64 - by SMcNeill - 11-14-2023, 09:52 PM
RE: pipecom on 3.9x verions of QB64 - by krovit - 11-15-2023, 09:32 AM



Users browsing this thread: 1 Guest(s)