* [#16639](https://bugzilla.scilab.org/16639): `atomsInstall` and `atomsRemove` did not update the Toolboxes menu.
* [#16644](https://bugzilla.scilab.org/16644): `input("message:")` yielded a wrong error message about `mprintf` in case of non-interpretable input.
* [#16654](https://bugzilla.scilab.org/16654): `interp` was leaking memory.
+* [#16661](https://bugzilla.scilab.org/16661): `x=spzeros(1e10,1e10)` yielded an incorrect error message.
* [#16665](https://bugzilla.scilab.org/16665): `help echo` could not redirect to `help mode` when preferred, for new users coming from Octave.
{
#include "charEncoding.h"
#include "Scierror.h"
+#include "sciprint.h"
#include "localization.h"
}
return types::Function::Error;
}
+ if ( pDdims->get(0) > (double) INT_MAX || pDdims->get(1) > (double) INT_MAX)
+ {
+ Scierror(999, _("%s: Wrong values for input argument #%d: Elements must be less than %d.\n"), "sparse", 3,INT_MAX);
+ return types::Function::Error;
+ }
+
if (pDdims->get(0) != (double) ( (unsigned int) pDdims->get(0) ) || pDdims->get(1) != (double) ( (unsigned int) pDdims->get(1) ))
{
Scierror(999, _("%s: Wrong values for input argument #%d: Positive integers expected.\n"), "sparse", 3);
return types::Function::Error;
}
- if (pDdims->get(0) * pDdims->get(1) > INT_MAX)
+ if (pDdims->get(0) * pDdims->get(1) > (double) INT_MAX)
{
- Scierror(999, _("%s: Wrong value for input argument #%d: The maximum total size expected is %d.\n"), "sparse", 3, INT_MAX);
- return types::Function::Error;
+ // FIXME: should be an error. To fix we need GenericType::m_iSize huger than int
+ if (getWarningMode())
+ {
+ sciprint(_("%s: Warning: You have created a Sparse of size > %d.\nDue to a Scilab limitation, reading or writing values from/to \nthis sparse using a unique index could lead to unexpected behavior."), "sparse", INT_MAX);
+ }
}
+
}
bool alloc = false;
{
#include "charEncoding.h"
#include "Scierror.h"
+#include "sciprint.h"
#include "localization.h"
}
double dblRows = pDblRows->get(0);
double dblCols = pDblCols->get(0);
+ if (dblRows > (double) INT_MAX)
+ {
+ Scierror(999, _("%s: Wrong value for input argument #%d: Must be less than %d.\n"), "spzeros", 1,INT_MAX);
+ return types::Function::Error;
+ }
if (dblRows != (double) ((unsigned int) dblRows))
{
Scierror(999, _("%s: Wrong value for input argument #%d: Scalar positive integer expected.\n"), "spzeros", 1);
return types::Function::Error;
}
+ if (dblCols > (double) INT_MAX)
+ {
+ Scierror(999, _("%s: Wrong value for input argument #%d: Must be less than %d.\n"), "spzeros", 2,INT_MAX);
+ return types::Function::Error;
+ }
if (dblCols != (double) ((unsigned int) dblCols))
{
- Scierror(999, _("%s: Wrong value for input argument #%d: Scalar positive integer expected.\n"), "spzeros", 2);
+ Scierror(999, _("%s: Wrong value for input argument #%d: Scalar positive integer expected.\n"), "spzeros", 1);
return types::Function::Error;
}
- if (dblRows * dblCols > INT_MAX)
+ if (dblRows * dblCols > (double) INT_MAX)
{
- Scierror(999, _("%s: Wrong value for input arguments: The maximum total size expected is %d.\n"), "spzeros", INT_MAX);
- return types::Function::Error;
+ // FIXME: should be an error. To fix we need GenericType::m_iSize huger than int
+ if (getWarningMode())
+ {
+ sciprint(_("%s: Warning: You have created a Sparse of size > %d.\nDue to a Scilab limitation, reading or writing values from/to \nthis sparse using a unique index could lead to unexpected behavior."), "sparse", INT_MAX);
+ }
}
if (pDblRows->get(0) == 0. || pDblCols->get(0) == 0.)
--- /dev/null
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2021 - 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 16661 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/16661
+//
+// <-- Short Description -->
+// x=spzeros(1e10,1e10) yields an incorrect error message
+
+INT_MAX = int32(%inf);
+
+cmd = "spzeros(1e10,1)";
+msg = msprintf(_("%s: Wrong value for input argument #%d: Must be less than %d.\n"),"spzeros",1, INT_MAX)
+assert_checkerror(cmd,msg);
+
+cmd = "spzeros(1,1e10)";
+msg = msprintf(_("%s: Wrong value for input argument #%d: Must be less than %d.\n"),"spzeros",2, INT_MAX)
+assert_checkerror(cmd,msg);
+
+cmd = "sparse([1 1],1,[1e10,1e10])";
+msg = msprintf(_("%s: Wrong values for input argument #%d: Elements must be less than %d.\n"),"sparse",3,INT_MAX)
+assert_checkerror(cmd,msg);