rstudio/rstudio — comment on commit e87fe766cfb2f27c9849da9dcb67e63c5a526624
File: src/cpp/core/tex/TexLogParser.cpp line 292
By jcheng5:

If it wasn't a function-scoped static (which it sounds like, since you said
"static via anonymous namespace") then it sounds like it was this...?
http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.14

The fix to that problem is to put it inside a function, so the initializer
doesn't run on module load but only the first time the function runs. Since
these are inside functions they ought to be OK.

Let me know if that makes you feel better...

On Fri, Feb 17, 2012 at 5:35 PM, JJ Allaire <
reply@reply.github.com
> wrote:

> You might think this is way too paranoid, but I once ran into trouble with
> statics that had constructor arguments (this was on Ubuntu). Here was the
> comment I made (this is over in the ServerGoogleDocs.cpp):
>
> // initialize server (create on the heap so it survives after this call)
> // note that we attempted to make this static via anonymous namespace
> // but on ubuntu server this resulted in the acceptor initialization
> failing
> // (presumably because the presence of a constructor argument on an
> // automatically initialized static gave the compiler problems?)
>
> As a result when I need to have a bunch of static regex's I use the
> pattern that you can see in RTokenizer.cpp. I realize that this is verging
> on voodoo paranoia but (a) I spent a lot of time hunting down the cause of
> that first bug; and (b) this is C++ after all ;-)
>
> ---
> Reply to this email directly or view it on GitHub:
>
> https://github.com/rstudio/rstudio/commit/e87fe766cfb2f27c9849da9dcb67e63c5a526624#commitcomment-980487
>