You're getting this message because you are using an undefined aspect of ++. Depending on compiler convention re. the interpretation of ++, your code may be interpreted differently; ie. different compilers will interpret the code differently. This is a bad thing.
You're presumably getting the warning now, because the compiler flag has been added on the Bioc build servers. There was a recent thread on this specific aspect of ++ recently, but I forgot which email list. Kasper On Mon, Jun 23, 2014 at 2:54 PM, cstrato <cstr...@aon.at> wrote: > Dear Romain, > > I do not know enough about compilers, but as far as I remember, they > 'work' from right to left, so numsels = ++numsels should not confuse the > compiler. Anyhow I will change my code to your first suggestion since it is > more elegant. > > Best regards, > Christian > > > > On 6/23/14 7:13 PM, Romain François wrote: > >> >> Le 23 juin 2014 à 18:28, cstrato <cstr...@aon.at> a écrit : >> >> Dear Romain, >>> >>> Thank you for your suggestions, I like especially the first one. >>> >>> However, you did not explain why I have never got this warning message >>> on any compiler, and why only one of the two identical Ubuntu compilers did >>> give this warning message? >>> >>> Best regards, >>> Christian >>> >> >> I donât know, but this: >> >> numsels = ++numsels ; >> >> seems fishy to me, and so it keeps feeling weird with the addition of the >> ternary operator. >> >> There is obviously a difference of setup between these two machines, but >> I donât have time to sherlock that for you. One of the compilers is getting >> more careful than the other. Getting warnings you did not get before is a >> good thing, as it helps you update the code with that new insight. >> >> Welcome to my world, Iâm sometimes thrown all kinds of new warnings from >> esoteric compilers, all of them have value . >> >> Romain >> >> On 6/23/14 3:45 PM, Romain François wrote: >>> >>>> >>>> Le 23 juin 2014 à 15:20, cstrato <cstr...@aon.at> a écrit : >>>> >>>> Dear all, >>>>> >>>>> Since many years the following C++ code does compile on ALL >>>>> Bioconductor servers (Linux, Windows, Mac) without any warnings: >>>>> >>>>> Int_t numsels = 0; //number of selected entries >>>>> ... >>>>> for (Int_t i=0; i<size; i++) { >>>>> numsels = (arrMask[i] == 1) ? ++numsels : numsels; >>>>> }//for_i >>>>> >>>> >>>> This is confusing. I would write the loop body like this: >>>> >>>> numsels += (arrMask[i] == 1) ; >>>> >>>> >>>> or preferably using the STL: >>>> >>>> Int_t numsels = std::count( begin(arrMask), end(arrMask), 1 ) ; >>>> >>>> or some other variation of this, i.e. perhaps you donât have a C++11 >>>> compiler, so perhaps one of these depending on what is arrMask: >>>> >>>> Int_t numsels = std::count( arrMask.begin(), arrMask.end(), 1 ) ; >>>> Int_t numsels = std::count( arrMask, arrMask + size, 1 ) ; >>>> >>>> Romain >>>> >>>> Even on the recently added release server 'zin2' Linux (Ubuntu 12.04.4 >>>>> LTS) the above code compiles w/o warnings. >>>>> >>>>> However, on the new development server 'zin1' Linux (Ubuntu 12.04.4 >>>>> LTS) I get suddenly the following warning message: >>>>> >>>>> Found the following significant warnings: >>>>> XPSPreProcessing.cxx:3026:56: warning: operation on ânumselsâ may be >>>>> undefined [-Wsequence-point] >>>>> >>>>> Interestingly, both servers do not only run the same version of >>>>> Ubuntu, but also the same version of the C++ compiler, i.e. g++ >>>>> (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3, and use the same flags, see: >>>>> http://bioconductor.org/checkResults/2.14/bioc-LATEST/ >>>>> zin2-NodeInfo.html >>>>> http://bioconductor.org/checkResults/devel/bioc- >>>>> LATEST/zin1-NodeInfo.html >>>>> >>>>> My question is now, why do I suddenly get the compiler warning? >>>>> >>>>> The reason why I ask at R-devel and not Bioc-devel is that it may not >>>>> only be a Bioc question, since I found the following links: >>>>> http://c-faq.com/expr/seqpoints.html >>>>> http://stackoverflow.com/questions/16838884/why-i-got- >>>>> operation-may-be-undefined-in-statement-expression-in-c >>>>> >>>>> I am not sure if I understand the meaning, but until now I have never >>>>> got any warning from any compiler the I have used (including MS Visual >>>>> C++). >>>>> >>>>> Do I really have to replace '++numsels' with 'numsels+1'? >>>>> >>>>> Best regards, >>>>> Christian >>>>> _._._._._._._._._._._._._._._._._._ >>>>> C.h.r.i.s.t.i.a.n S.t.r.a.t.o.w.a >>>>> V.i.e.n.n.a A.u.s.t.r.i.a >>>>> e.m.a.i.l: cstrato at aon.at >>>>> _._._._._._._._._._._._._._._._._._ >>>>> >>>>> ______________________________________________ >>>>> R-devel@r-project.org mailing list >>>>> https://stat.ethz.ch/mailman/listinfo/r-devel >>>>> >>>> >>>> >>>> >> >> > ______________________________________________ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > [[alternative HTML version deleted]]
______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel