mcs optimises falsly code out in "if ( ... &&false)

Bug #144734 reported by Test-tools on 2007-09-25
2
Affects Status Importance Assigned to Milestone
mono
Fix Released
Medium
mono (Ubuntu)
Undecided
Unassigned

Bug Description

Binary package hint: mono-mcs

My collegue Martin Zaworski found a misbehaviour, we have then tracked it down to following:
if (foo++ && false) {
} else {
   //foo isn't incremented
}
So, in an conditional statement, with &&false, the left hand side doesn't run(or gets compiled), no side effects are
executed. Also no function() can be called inside there).
Works also with assignments, optimisation switches don't matter.

Microsoft csc.exe is void of that problem

Package: mono-mcs 1.2.4-6ubuntu4
Also affected is the current svn version (21/9/2007).

We have here now untrusted compiled binaries, unless it's verificable, that this kind of source coding isn't used,
they have to be recompiled with a fixed version of the compiler.

Test-tools (roland-verifysoft) wrote :
Test-tools (roland-verifysoft) wrote :

To clarify, this bug is not fixed and exists in current svn, output of svn info:

Path: .
URL: svn://anonsvn.mono-project.com/source/trunk/mcs
Repository Root: svn://anonsvn.mono-project.com/source
Repository UUID: e3ebcda4-bce8-0310-ba0a-eca2169e7518
Revision: 86462
Node Kind: directory
Schedule: normal
Last Changed Author: mhabersack
Last Changed Rev: 86461
Last Changed Date: 2007-09-27 10:17:33 +0300 (Do, 27 Sep 2007)

Changed in mono:
status: Unknown → Confirmed
Test-tools (roland-verifysoft) wrote :

The problem is related to the Logical And Expression, doesn't matter if it's inside if().

The left hand side gets just completly optimised out, if the right hand side resolves at compilation time to true,

(adding a new testcase).

Test-tools (roland-verifysoft) wrote :

Corrigendum to my last message:

"if the right hand side resolves at compilation time to true,"
should be
"if the right hand side resolves at compilation time to false,"

Test-tools (roland-verifysoft) wrote :

Still present in 1.2.6.0
Mono C# compiler version 1.2.6.0

Changed in mono:
status: Confirmed → Fix Released
Jo Shields (directhex) wrote :

Still present in 1.9.1 9Intrepid), will be fixed in post-Intrepid releases

Changed in mono:
status: New → Confirmed
Jo Shields (directhex) wrote :

Fixed in Jaunty

Changed in mono:
status: Confirmed → Fix Released
Changed in mono:
importance: Unknown → Medium
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.