From: Stéphane Mottelet Date: Fri, 10 Apr 2020 09:19:46 +0000 (+0200) Subject: * Bug 16350 fixed: now empty sparse bool matrix is false in cond exp X-Git-Url: http://gitweb.scilab.org/?p=scilab.git;a=commitdiff_plain;h=8e4c2bccea6da400b3fda19de97aa9d971b66b93 * Bug 16350 fixed: now empty sparse bool matrix is false in cond exp http://bugzilla.scilab.org/show_bug.cgi?id=16350 Change-Id: I626fb459edbeb140b748074232a96abc0b67103b --- diff --git a/scilab/CHANGES.md b/scilab/CHANGES.md index 49f0d86..e1772d4 100644 --- a/scilab/CHANGES.md +++ b/scilab/CHANGES.md @@ -267,6 +267,7 @@ Bug Fixes ### Bugs fixed in 6.1.1: * [#3188](https://bugzilla.scilab.org/3188): `part()` was slower than in Scilab 4.1.2. * [#16342](https://bugzilla.scilab.org/16342): `strcat()` was much slower in Scilab 6.0.2. +* [#16350](https://bugzilla.scilab.org/16350): in if/while conditions, the empty sparse boolean was considered as TRUE. * [#16365](https://bugzilla.scilab.org/16365): `median(m,"r")` and `median(m,"c")` yielded wrong results (6.1.0 regression) ### Bugs fixed in 6.1.0: diff --git a/scilab/modules/ast/includes/types/sparse.hxx b/scilab/modules/ast/includes/types/sparse.hxx index 7731b46..e662a83 100644 --- a/scilab/modules/ast/includes/types/sparse.hxx +++ b/scilab/modules/ast/includes/types/sparse.hxx @@ -599,7 +599,7 @@ struct EXTERN_AST SparseBool : GenericType bool isTrue() { - if (static_cast(nbTrue()) == m_iSize) + if (m_iSize > 0 && static_cast(nbTrue()) == m_iSize) { return true; } diff --git a/scilab/modules/ast/tests/nonreg_tests/bug_16350.tst b/scilab/modules/ast/tests/nonreg_tests/bug_16350.tst new file mode 100644 index 0000000..8af1ee0 --- /dev/null +++ b/scilab/modules/ast/tests/nonreg_tests/bug_16350.tst @@ -0,0 +1,23 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2020 - Stéphane MOTTELET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// <-- NO CHECK REF --> +// +// <-- Non-regression test for bug 16350 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/16350 +// +// <-- Short Description --> +// In if/while conditions, the empty sparse boolean is considered as TRUE. + +a = sparse(1)<2; +a(1) = []; +b = 1; +if a, b = 2; end +assert_checkequal(b,1);