--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To post to this group, send email to c...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CANHK6RYpBB%3D-LY2BB%2Begp9f9D%2BRrjJUXrUOKRrrjURX-PtAh5g%40mail.gmail.com.
How is it broken? It fails to enforce thread safety?
--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To post to this group, send email to c...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CABdywOeNz0Ao46-7SZpgwkeCBYmsg3932mb3Csu3p4uEcvzWpA%40mail.gmail.com.
Nit: that page says right at the top, "Unlike the style guide, the content of this page is advisory, not required." So there's a bit lower bar for usage of "magic statics" to have snuck in.
$ cat ~/magic-static.ccextern int magic();int user() {static int m = magic();return m;}$ /s/llvm/out/bin/clang++ -std=c++11 -O2 -S ~/magic-static.cc -o - | c++filt.text.file "/usr/local/google/home/jfb/magic-static.cc".globl user().align 16, 0x90.type user(),@functionuser(): # @user().Lfunc_begin0:.cfi_startproc.cfi_personality 3, __gxx_personality_v0.cfi_lsda 3, .Lexception0# BB#0: # %entrypushq %rbx.Ltmp3:.cfi_def_cfa_offset 16.Ltmp4:.cfi_offset %rbx, -16movb guard variable for user()::m(%rip), %altestb %al, %aljne .LBB0_4# BB#1: # %init.checkmovl guard variable for user()::m, %edicallq __cxa_guard_acquiretestl %eax, %eaxje .LBB0_4# BB#2: # %init.Ltmp0:callq magic().Ltmp1:# BB#3: # %invoke.contmovl %eax, user()::m(%rip)movl guard variable for user()::m, %edicallq __cxa_guard_release.LBB0_4: # %init.endmovl user()::m(%rip), %eaxpopq %rbxretq