g++ and suppressing threadsafe-statics

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

following is an example regarding the generation of guards for the
static m in template X.

My goal ist to suppress(!) the generation of the guards (for use on
microcontroller).

1) If no user-defined ctors are used, no guards are generated
2) With anon-ns, no guards are generated

But even

3) if I make it a local static instead as a static member and use
-fno-threadsafe-statics, the guards are generated

Option 1) or 2) are not applicable for me, so I went for option 3), but
that did not work either.

Any hints?
 Wilhelm

// Test für guard variable

struct A {
    inline A(int v = 0) {} // without user-defined ctors, guards are omitted
    int m1() const {
        return m;
    }
private:
    int m = 0;
};

//namespace { // without anon-ns guards, are generated
    template<typename T>
    struct X {
        static int foo() {
//            static T m; // even as local-static and
-fno-threadsafe-statics, guards are generated
            return m.m1();
        }
        inline static T m;
    };
//}

int main() {
    return X<A>::foo();
}




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux