<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jul 1, 2014 at 5:39 AM, Aleix Pol <span dir="ltr"><<a href="mailto:aleixpol@kde.org" target="_blank">aleixpol@kde.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div class="">On Tue, Jul 1, 2014 at 5:03 AM, Nicolás Alvarez <span dir="ltr"><<a href="mailto:nicolas.alvarez@gmail.com" target="_blank">nicolas.alvarez@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi peeps,<br>
<br>
In analitza/commands/blockmatrixcommands.cpp, there is a variable-length array:<br>
<br>
const int firstVectorSize = firstVector->size();<br>
int blockpattern[firstVectorSize];<br>
<br>
This is a new feature in C99. The GCC manual says: "Variable-length<br>
automatic arrays are allowed in ISO C99, and as an extension GCC<br>
accepts them in C90 mode and in C++."<br>
<br>
MSVC doesn't support VLAs, at least not in C++ mode. And given the<br>
above quote, it seems it's non-portable to use it in C++ anyway, so<br>
(this time :P) we can't blame it on MSVC not being standards-compliant<br>
or something.<br>
<br>
I replaced it with this to make it compile:<br>
std::unique_ptr<int[]> blockpattern(new int[firstVectorSize]);<br>
<br>
But I don't know if this is acceptable (can I use C++11 in analitza?).<br>
##c++ told me to just use<br>
std::vector<int> blockpattern(firstVectorSize, 0);<br>
<br>
which is a reasonable option, but it feels weird to use a std::vector<br>
for something that won't be resized.<br>
<br>
I welcome thoughts from someone who actually knows the Analitza code :)<br><br></blockquote><div><br></div></div><div>Hi,</div><div>Wouldn't that fix the issue?</div><div><br></div><div>Aleix</div><div><br></div><div>
diff --git analitza/commands/blockmatrixcommands.cpp analitza/commands/blockmatrixcommands.cpp</div>

<div>index 6ff20ef..568fbde 100644</div><div>--- analitza/commands/blockmatrixcommands.cpp</div><div>+++ analitza/commands/blockmatrixcommands.cpp</div><div>@@ -62,7 +62,7 @@ Expression BlockMatrixCommand::operator()(const QList< Analitza::Expression >& a</div>


<div> <span style="white-space:pre-wrap">                                </span>bool isCorrect = true; // this flag tells if is ok to build the block matrix</div><div> <span style="white-space:pre-wrap">                           </span>int nrows = 0;</div><div> <span style="white-space:pre-wrap">                         </span>int ncols = 0;</div>


<div>-<span style="white-space:pre-wrap">                         </span>int blockpattern[firstVectorSize]; // if vectors(matrixrow) this tells the row(column) pattern</div><div>+<span style="white-space:pre-wrap">                          </span>std::vector<int> blockpattern(firstVectorSize, 0); // if vectors(matrixrow) this tells the row(column) pattern</div>


<div> <span style="white-space:pre-wrap">                                </span></div><div> <span style="white-space:pre-wrap">                               </span>const int blocklength = isVector? firstBlock->columnCount() : firstBlock->rowCount();</div><div>
 <span style="white-space:pre-wrap">                           </span></div>
<div> </div></div></div><div class="gmail_extra"><br></div></div></blockquote><div><br></div><div>Hi Nicolás, </div><div><br></div><div>Please confirm us if the fix provided by Aleix is enough, I remember I did some test with that approach (using std::vector) and it works ok ... even more, I'm a bit surprised I left the code with a raw C99 array instead of std::vector ... :p</div>
<div><br></div><div>Thanks ;)</div><div>Percy </div><div><br></div></div></div></div>