Stack Overflow Weekly Newsletter
Stack Overflow Weekly Newsletter

Top new questions this week:

What is this JavaScript pattern called and why is it used?

I'm studying THREE.js and noticed a pattern where functions are defined like so: var foo = ( function () { var tmpObject = new Bar(); return function ( ) { //actual logic using …

javascript closures iife  
asked by Patrick Klug 50 votes
answered by MD. Sahib Bin Mahboob 42 votes

Why does adding 0.1 multiple times remain lossless?

I know the 0.1 decimal number cannot be represented exactly with a finite binary number (explanation), so double n = 0.1 will lose some precision and will not be exactly 0.1. On the other hand 0.5 can …

java floating-point floating-point-precision  
asked by icza 43 votes
answered by Peter Lawrey 55 votes

Is the behavior behind the Shell Shock vulnerability in Bash documented or at all intentional?

A recent vulnerability, CVE-2014-6271, in how bash interprets environment variables was disclosed. The exploit relies on bash parsing some environment variable declarations as function definitions, …

bash function security environment-variables shellshock-bash-bug  
asked by kojiro 34 votes
answered by Barmar 35 votes

Why does GCC implement isnan() more efficiently for C++ <cmath> than C <math.h>?

Here's my code: int f(double x) { return isnan(x); } If I #include <cmath> I get this assembly: xorl %eax, %eax ucomisd %xmm0, %xmm0 setp %al This is reasonably clever: ucomisd …

c++ c optimization nan constantfolding  
asked by John Zwinck 30 votes
answered by Rapptz 8 votes

Why are std::fstreams so slow?

I was working on a simple parser and when profiling I observed the bottleneck is in... file read! I extracted very simple test to compare the performance of fstreams and FILE* when reading a big blob …

c++ performance  
asked by Felics 26 votes
answered by Mats Petersson 11 votes

Why is this function call ambiguous?

I'm reading the standard and trying to figure out why this code won't be resolved without a cast. void foo(char c) { } // Way bigger than char void foo(unsigned long int) { } int main() { …

c++ integer implicit-conversion unsigned-integer integer-promotion  
asked by user4073503 25 votes
answered by AndreyT 45 votes

Why does the order of template parameters matter to the MS C++ compiler in this example?

The following code compiles fine in GCC but in Visual Studio it results in error C2782: 'bool contains(const T &,const std::initializer_list<T2> &)' : template parameter 'T' is …

c++ templates visual-c++ c++11  
asked by Sarien 24 votes
answered by Jared Grubb 0 votes

Greatest hits from previous weeks:

What and where are the stack and heap?

Programming language books usually explain that value types are created on the stack, and reference types are created on the heap, without really explaining what these two things are. With my only …

memory-management data-structures stack comparison heap  
asked by mattshane 3139 votes
answered by Jeff Hill 2209 votes

Using global variables in a function other than the one that created them

If I create a global variable in one function, how can I use that variable in another function? Do I need to store the global variable in a local variable of the function which needs its access?

python scope global-variables variable-scope  
asked by user46646 825 votes
answered by Paul Stephenson 1248 votes

Can you answer these?

Chrome DevTools [chrome://inspect] : 404 Not Found The resource could not be found

I used "chrome://inspect" for a few days. Everything was fine. Today, for some reason, when I click "inspect" the result is "404 Not Found The resource could not be found." What could be the reason …

google-chrome google-chrome-devtools  
asked by Sams 11 votes

Does PyPDF2 take any safety measures when opening an unsafe file?

I'm wanting to use PyPDF2, but first wanted to make sure that it would be safe to use. I'm unable to find anything in it's docs. I want to use it to make sure that uploaded files are valid PDFs. Users …

python django python-2.7 pypdf  
asked by Taylor Hobbs 5 votes

Application crashes on iOS8 only due to Memory Error

I am trying to generate graph and take its screenshot one by one. The application works fine for once and then when I try to capture screenshots again the second time, the application crashes saying …

ios objective-c ipad memory ios8  
asked by Sharon Nathaniel 5 votes
Subscribe to more Stack Exchange newsletters


Unsubscribe from this newsletter or change your email preferences by visiting your subscriptions page on stackexchange.com.

Questions? Comments? Let us know on our feedback site. If you no longer want to receive mail from Stack Exchange, unsubscribe from all stackexchange.com emails.

Stack Exchange, Inc. 110 William St, 28th Floor, NY NY 10038 <3