Usage before initialization of const member, is this expected bahviour of gcc and clang? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!How to initialize private static members in C++?Clang vs GCC - which produces better binaries?Why does not g++ or clang elicit a warning when truncating a non-const variable by assigning it to a variable of smaller type?Switching between GCC and Clang/LLVM using CMakeClang vs GCC for my Linux Development projectWarnings to determine unsafe casts clangComparing two map::iterators: why does it need the copy constructor of std::pair?Defining a std::map with an undefined comparison function compiles and links, which surprises me`auto x = type…` initialization syntax and `explicit` conversion operator - clang vs gccWarning for a cast from a char literal to a char *

Why is it faster to reheat something than it is to cook it?

What was the first language to use conditional keywords?

An adverb for when you're not exaggerating

What are the diatonic extended chords of C major?

Is it a good idea to use CNN to classify 1D signal?

Effects on objects due to a brief relocation of massive amounts of mass

How do living politicians protect their readily obtainable signatures from misuse?

Why weren't discrete x86 CPUs ever used in game hardware?

What does it mean that physics no longer uses mechanical models to describe phenomena?

Do I really need to have a message in a novel to appeal to readers?

Is it fair for a professor to grade us on the possession of past papers?

Significance of Cersei's obsession with elephants?

Is there any word for a place full of confusion?

Can a new player join a group only when a new campaign starts?

Did Deadpool rescue all of the X-Force?

How to compare two different files line by line in unix?

Illegal assignment from sObject to Id

Why is Nikon 1.4g better when Nikon 1.8g is sharper?

When a candle burns, why does the top of wick glow if bottom of flame is hottest?

How does the math work when buying airline miles?

Selecting user stories during sprint planning

Why do early math courses focus on the cross sections of a cone and not on other 3D objects?

Is there hard evidence that the grant peer review system performs significantly better than random?

Using audio cues to encourage good posture



Usage before initialization of const member, is this expected bahviour of gcc and clang?



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!How to initialize private static members in C++?Clang vs GCC - which produces better binaries?Why does not g++ or clang elicit a warning when truncating a non-const variable by assigning it to a variable of smaller type?Switching between GCC and Clang/LLVM using CMakeClang vs GCC for my Linux Development projectWarnings to determine unsafe casts clangComparing two map::iterators: why does it need the copy constructor of std::pair?Defining a std::map with an undefined comparison function compiles and links, which surprises me`auto x = type…` initialization syntax and `explicit` conversion operator - clang vs gccWarning for a cast from a char literal to a char *



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















Consider the following snippet. Class test has a const member a and a member function fun which returns a. An initialization list is used to to initialize a in the constructor. However in the initialization list a lambda is used to initialize a with the returned value of fun. This leads to different behaviors of clang and gcc at compile and runtime, depending on the optimization level. Below the snippet and the different outputs at compile and runtime are listed. Is this expected behavior of gcc and clang?



#include <iostream>

class test
public:
const int a;

test(): a([this]()return fun();())

int fun()

return a;

;

int main()

auto t = test();
std::cout << t.a << 'n';
return 0;



Compiletime:



clang++-5.0 -std=c++17 -Wall -Wextra -Weverything

lambda_in_initializer_list.cpp:7:15: warning: lambda expressions are incompatible with C++98
[-Wc++98-compat]
test(): a([this]()return fun();())
^
warning: 'auto' type specifier is incompatible with C++98 [-Wc++98-compat]
lambda_in_initializer_list.cpp:17:5: warning: 'auto' type specifier is incompatible with C++98
[-Wc++98-compat]
auto t = test();
^~~~
3 warnings generated.



clang++-5.0 -std=c++17 -Wall -Wextra -Weverything -O1

lambda_in_initializer_list.cpp:7:15: warning: lambda expressions are incompatible with C++98
[-Wc++98-compat]
test(): a([this]()return fun();())
^
warning: 'auto' type specifier is incompatible with C++98 [-Wc++98-compat]
lambda_in_initializer_list.cpp:17:5: warning: 'auto' type specifier is incompatible with C++98
[-Wc++98-compat]
auto t = test();
^~~~



g++ -std=c++17 -Wall -Wextra -Wpedantic

No output



g++ -std=c++17 -Wall -Wextra -Wpedantic -O1

lambda_in_initializer_list.cpp: In function ‘int main()’:
lambda_in_initializer_list.cpp:18:20: warning: ‘t.test::a’ is used uninitialized in this function [-Wuninitialized]
std::cout << t.a << 'n';
~~^


Runtime:



clang++-5.0 -std=c++17 -Wall -Wextra -Weverything

0



clang++-5.0 -std=c++17 -Wall -Wextra -Weverything -O1

4196112



g++ -std=c++17 -Wall -Wextra -Wpedantic

Non deterministic output.



g++ -std=c++17 -Wall -Wextra -Wpedantic -O1

0









share|improve this question



















  • 1





    What deterministic value you would have expected?

    – Guillaume Racicot
    Mar 8 at 20:48






  • 5





    You have undefined behavior. All results are valid

    – NathanOliver
    Mar 8 at 20:49











  • Of course this is not the correct way of initializing the variable. I would expect clang to warn me and gcc to warn me not only when optimization is turned on. I would also expect the program to print the same value regardless of the optimization level.

    – user3457151
    Mar 8 at 20:52











  • Welcome to UB land. The compiler doesn't have to tell you about it and different implementations can do different things. You can even get different things from each run of the same binary.

    – NathanOliver
    Mar 8 at 21:05






  • 1





    -Weverything is not a good idea

    – sp2danny
    Mar 8 at 21:17

















0















Consider the following snippet. Class test has a const member a and a member function fun which returns a. An initialization list is used to to initialize a in the constructor. However in the initialization list a lambda is used to initialize a with the returned value of fun. This leads to different behaviors of clang and gcc at compile and runtime, depending on the optimization level. Below the snippet and the different outputs at compile and runtime are listed. Is this expected behavior of gcc and clang?



#include <iostream>

class test
public:
const int a;

test(): a([this]()return fun();())

int fun()

return a;

;

int main()

auto t = test();
std::cout << t.a << 'n';
return 0;



Compiletime:



clang++-5.0 -std=c++17 -Wall -Wextra -Weverything

lambda_in_initializer_list.cpp:7:15: warning: lambda expressions are incompatible with C++98
[-Wc++98-compat]
test(): a([this]()return fun();())
^
warning: 'auto' type specifier is incompatible with C++98 [-Wc++98-compat]
lambda_in_initializer_list.cpp:17:5: warning: 'auto' type specifier is incompatible with C++98
[-Wc++98-compat]
auto t = test();
^~~~
3 warnings generated.



clang++-5.0 -std=c++17 -Wall -Wextra -Weverything -O1

lambda_in_initializer_list.cpp:7:15: warning: lambda expressions are incompatible with C++98
[-Wc++98-compat]
test(): a([this]()return fun();())
^
warning: 'auto' type specifier is incompatible with C++98 [-Wc++98-compat]
lambda_in_initializer_list.cpp:17:5: warning: 'auto' type specifier is incompatible with C++98
[-Wc++98-compat]
auto t = test();
^~~~



g++ -std=c++17 -Wall -Wextra -Wpedantic

No output



g++ -std=c++17 -Wall -Wextra -Wpedantic -O1

lambda_in_initializer_list.cpp: In function ‘int main()’:
lambda_in_initializer_list.cpp:18:20: warning: ‘t.test::a’ is used uninitialized in this function [-Wuninitialized]
std::cout << t.a << 'n';
~~^


Runtime:



clang++-5.0 -std=c++17 -Wall -Wextra -Weverything

0



clang++-5.0 -std=c++17 -Wall -Wextra -Weverything -O1

4196112



g++ -std=c++17 -Wall -Wextra -Wpedantic

Non deterministic output.



g++ -std=c++17 -Wall -Wextra -Wpedantic -O1

0









share|improve this question



















  • 1





    What deterministic value you would have expected?

    – Guillaume Racicot
    Mar 8 at 20:48






  • 5





    You have undefined behavior. All results are valid

    – NathanOliver
    Mar 8 at 20:49











  • Of course this is not the correct way of initializing the variable. I would expect clang to warn me and gcc to warn me not only when optimization is turned on. I would also expect the program to print the same value regardless of the optimization level.

    – user3457151
    Mar 8 at 20:52











  • Welcome to UB land. The compiler doesn't have to tell you about it and different implementations can do different things. You can even get different things from each run of the same binary.

    – NathanOliver
    Mar 8 at 21:05






  • 1





    -Weverything is not a good idea

    – sp2danny
    Mar 8 at 21:17













0












0








0








Consider the following snippet. Class test has a const member a and a member function fun which returns a. An initialization list is used to to initialize a in the constructor. However in the initialization list a lambda is used to initialize a with the returned value of fun. This leads to different behaviors of clang and gcc at compile and runtime, depending on the optimization level. Below the snippet and the different outputs at compile and runtime are listed. Is this expected behavior of gcc and clang?



#include <iostream>

class test
public:
const int a;

test(): a([this]()return fun();())

int fun()

return a;

;

int main()

auto t = test();
std::cout << t.a << 'n';
return 0;



Compiletime:



clang++-5.0 -std=c++17 -Wall -Wextra -Weverything

lambda_in_initializer_list.cpp:7:15: warning: lambda expressions are incompatible with C++98
[-Wc++98-compat]
test(): a([this]()return fun();())
^
warning: 'auto' type specifier is incompatible with C++98 [-Wc++98-compat]
lambda_in_initializer_list.cpp:17:5: warning: 'auto' type specifier is incompatible with C++98
[-Wc++98-compat]
auto t = test();
^~~~
3 warnings generated.



clang++-5.0 -std=c++17 -Wall -Wextra -Weverything -O1

lambda_in_initializer_list.cpp:7:15: warning: lambda expressions are incompatible with C++98
[-Wc++98-compat]
test(): a([this]()return fun();())
^
warning: 'auto' type specifier is incompatible with C++98 [-Wc++98-compat]
lambda_in_initializer_list.cpp:17:5: warning: 'auto' type specifier is incompatible with C++98
[-Wc++98-compat]
auto t = test();
^~~~



g++ -std=c++17 -Wall -Wextra -Wpedantic

No output



g++ -std=c++17 -Wall -Wextra -Wpedantic -O1

lambda_in_initializer_list.cpp: In function ‘int main()’:
lambda_in_initializer_list.cpp:18:20: warning: ‘t.test::a’ is used uninitialized in this function [-Wuninitialized]
std::cout << t.a << 'n';
~~^


Runtime:



clang++-5.0 -std=c++17 -Wall -Wextra -Weverything

0



clang++-5.0 -std=c++17 -Wall -Wextra -Weverything -O1

4196112



g++ -std=c++17 -Wall -Wextra -Wpedantic

Non deterministic output.



g++ -std=c++17 -Wall -Wextra -Wpedantic -O1

0









share|improve this question
















Consider the following snippet. Class test has a const member a and a member function fun which returns a. An initialization list is used to to initialize a in the constructor. However in the initialization list a lambda is used to initialize a with the returned value of fun. This leads to different behaviors of clang and gcc at compile and runtime, depending on the optimization level. Below the snippet and the different outputs at compile and runtime are listed. Is this expected behavior of gcc and clang?



#include <iostream>

class test
public:
const int a;

test(): a([this]()return fun();())

int fun()

return a;

;

int main()

auto t = test();
std::cout << t.a << 'n';
return 0;



Compiletime:



clang++-5.0 -std=c++17 -Wall -Wextra -Weverything

lambda_in_initializer_list.cpp:7:15: warning: lambda expressions are incompatible with C++98
[-Wc++98-compat]
test(): a([this]()return fun();())
^
warning: 'auto' type specifier is incompatible with C++98 [-Wc++98-compat]
lambda_in_initializer_list.cpp:17:5: warning: 'auto' type specifier is incompatible with C++98
[-Wc++98-compat]
auto t = test();
^~~~
3 warnings generated.



clang++-5.0 -std=c++17 -Wall -Wextra -Weverything -O1

lambda_in_initializer_list.cpp:7:15: warning: lambda expressions are incompatible with C++98
[-Wc++98-compat]
test(): a([this]()return fun();())
^
warning: 'auto' type specifier is incompatible with C++98 [-Wc++98-compat]
lambda_in_initializer_list.cpp:17:5: warning: 'auto' type specifier is incompatible with C++98
[-Wc++98-compat]
auto t = test();
^~~~



g++ -std=c++17 -Wall -Wextra -Wpedantic

No output



g++ -std=c++17 -Wall -Wextra -Wpedantic -O1

lambda_in_initializer_list.cpp: In function ‘int main()’:
lambda_in_initializer_list.cpp:18:20: warning: ‘t.test::a’ is used uninitialized in this function [-Wuninitialized]
std::cout << t.a << 'n';
~~^


Runtime:



clang++-5.0 -std=c++17 -Wall -Wextra -Weverything

0



clang++-5.0 -std=c++17 -Wall -Wextra -Weverything -O1

4196112



g++ -std=c++17 -Wall -Wextra -Wpedantic

Non deterministic output.



g++ -std=c++17 -Wall -Wextra -Wpedantic -O1

0






c++ gcc clang compiler-warnings






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 20:53









Guillaume Racicot

16.6k53872




16.6k53872










asked Mar 8 at 20:44









user3457151user3457151

4314




4314







  • 1





    What deterministic value you would have expected?

    – Guillaume Racicot
    Mar 8 at 20:48






  • 5





    You have undefined behavior. All results are valid

    – NathanOliver
    Mar 8 at 20:49











  • Of course this is not the correct way of initializing the variable. I would expect clang to warn me and gcc to warn me not only when optimization is turned on. I would also expect the program to print the same value regardless of the optimization level.

    – user3457151
    Mar 8 at 20:52











  • Welcome to UB land. The compiler doesn't have to tell you about it and different implementations can do different things. You can even get different things from each run of the same binary.

    – NathanOliver
    Mar 8 at 21:05






  • 1





    -Weverything is not a good idea

    – sp2danny
    Mar 8 at 21:17












  • 1





    What deterministic value you would have expected?

    – Guillaume Racicot
    Mar 8 at 20:48






  • 5





    You have undefined behavior. All results are valid

    – NathanOliver
    Mar 8 at 20:49











  • Of course this is not the correct way of initializing the variable. I would expect clang to warn me and gcc to warn me not only when optimization is turned on. I would also expect the program to print the same value regardless of the optimization level.

    – user3457151
    Mar 8 at 20:52











  • Welcome to UB land. The compiler doesn't have to tell you about it and different implementations can do different things. You can even get different things from each run of the same binary.

    – NathanOliver
    Mar 8 at 21:05






  • 1





    -Weverything is not a good idea

    – sp2danny
    Mar 8 at 21:17







1




1





What deterministic value you would have expected?

– Guillaume Racicot
Mar 8 at 20:48





What deterministic value you would have expected?

– Guillaume Racicot
Mar 8 at 20:48




5




5





You have undefined behavior. All results are valid

– NathanOliver
Mar 8 at 20:49





You have undefined behavior. All results are valid

– NathanOliver
Mar 8 at 20:49













Of course this is not the correct way of initializing the variable. I would expect clang to warn me and gcc to warn me not only when optimization is turned on. I would also expect the program to print the same value regardless of the optimization level.

– user3457151
Mar 8 at 20:52





Of course this is not the correct way of initializing the variable. I would expect clang to warn me and gcc to warn me not only when optimization is turned on. I would also expect the program to print the same value regardless of the optimization level.

– user3457151
Mar 8 at 20:52













Welcome to UB land. The compiler doesn't have to tell you about it and different implementations can do different things. You can even get different things from each run of the same binary.

– NathanOliver
Mar 8 at 21:05





Welcome to UB land. The compiler doesn't have to tell you about it and different implementations can do different things. You can even get different things from each run of the same binary.

– NathanOliver
Mar 8 at 21:05




1




1





-Weverything is not a good idea

– sp2danny
Mar 8 at 21:17





-Weverything is not a good idea

– sp2danny
Mar 8 at 21:17












2 Answers
2






active

oldest

votes


















3














I didn't quite understood a question, but it seems like you are actually asking 'why gcc didn't warn you until you turned up optimization'.



This is a known thing. Detecting undefined behavior in complex cases requires quite a lot of efforts on compiler side, and often is only done when you are optimizing code (since compiler is doing a lot of work anyways). Just something to keep in mind when you are dealing with real life-compilers.






share|improve this answer






























    2














    You have undefined behaviour. You use the value of a before initialization. If you want your program to be valid, initialize your variable before using it.



    struct test 
    int a;

    test(): a(0) // Effectively return the value of a,
    // which is 0 at this point.
    // ~~~~~~~v~~~~
    a = [this] return fun(); ();


    int fun()

    return a;

    ;

    int main()

    auto t = test();
    std::cout << t.a << 'n';
    return 0;



    Your compilers even warned you about your code. Listen to them. The warning were right, your code was invalid.






    share|improve this answer

























    • Clang did not warn me about this. Only gcc at optimazation level one warned me.

      – user3457151
      Mar 8 at 20:57












    • @user3457151 yes. Compilers are not required to find all possible warnings one would expect. They're only there to help you if the compiler find something odd.

      – Guillaume Racicot
      Mar 8 at 20:58












    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55070740%2fusage-before-initialization-of-const-member-is-this-expected-bahviour-of-gcc-an%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    I didn't quite understood a question, but it seems like you are actually asking 'why gcc didn't warn you until you turned up optimization'.



    This is a known thing. Detecting undefined behavior in complex cases requires quite a lot of efforts on compiler side, and often is only done when you are optimizing code (since compiler is doing a lot of work anyways). Just something to keep in mind when you are dealing with real life-compilers.






    share|improve this answer



























      3














      I didn't quite understood a question, but it seems like you are actually asking 'why gcc didn't warn you until you turned up optimization'.



      This is a known thing. Detecting undefined behavior in complex cases requires quite a lot of efforts on compiler side, and often is only done when you are optimizing code (since compiler is doing a lot of work anyways). Just something to keep in mind when you are dealing with real life-compilers.






      share|improve this answer

























        3












        3








        3







        I didn't quite understood a question, but it seems like you are actually asking 'why gcc didn't warn you until you turned up optimization'.



        This is a known thing. Detecting undefined behavior in complex cases requires quite a lot of efforts on compiler side, and often is only done when you are optimizing code (since compiler is doing a lot of work anyways). Just something to keep in mind when you are dealing with real life-compilers.






        share|improve this answer













        I didn't quite understood a question, but it seems like you are actually asking 'why gcc didn't warn you until you turned up optimization'.



        This is a known thing. Detecting undefined behavior in complex cases requires quite a lot of efforts on compiler side, and often is only done when you are optimizing code (since compiler is doing a lot of work anyways). Just something to keep in mind when you are dealing with real life-compilers.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 8 at 21:18









        SergeyASergeyA

        45.2k53990




        45.2k53990























            2














            You have undefined behaviour. You use the value of a before initialization. If you want your program to be valid, initialize your variable before using it.



            struct test 
            int a;

            test(): a(0) // Effectively return the value of a,
            // which is 0 at this point.
            // ~~~~~~~v~~~~
            a = [this] return fun(); ();


            int fun()

            return a;

            ;

            int main()

            auto t = test();
            std::cout << t.a << 'n';
            return 0;



            Your compilers even warned you about your code. Listen to them. The warning were right, your code was invalid.






            share|improve this answer

























            • Clang did not warn me about this. Only gcc at optimazation level one warned me.

              – user3457151
              Mar 8 at 20:57












            • @user3457151 yes. Compilers are not required to find all possible warnings one would expect. They're only there to help you if the compiler find something odd.

              – Guillaume Racicot
              Mar 8 at 20:58
















            2














            You have undefined behaviour. You use the value of a before initialization. If you want your program to be valid, initialize your variable before using it.



            struct test 
            int a;

            test(): a(0) // Effectively return the value of a,
            // which is 0 at this point.
            // ~~~~~~~v~~~~
            a = [this] return fun(); ();


            int fun()

            return a;

            ;

            int main()

            auto t = test();
            std::cout << t.a << 'n';
            return 0;



            Your compilers even warned you about your code. Listen to them. The warning were right, your code was invalid.






            share|improve this answer

























            • Clang did not warn me about this. Only gcc at optimazation level one warned me.

              – user3457151
              Mar 8 at 20:57












            • @user3457151 yes. Compilers are not required to find all possible warnings one would expect. They're only there to help you if the compiler find something odd.

              – Guillaume Racicot
              Mar 8 at 20:58














            2












            2








            2







            You have undefined behaviour. You use the value of a before initialization. If you want your program to be valid, initialize your variable before using it.



            struct test 
            int a;

            test(): a(0) // Effectively return the value of a,
            // which is 0 at this point.
            // ~~~~~~~v~~~~
            a = [this] return fun(); ();


            int fun()

            return a;

            ;

            int main()

            auto t = test();
            std::cout << t.a << 'n';
            return 0;



            Your compilers even warned you about your code. Listen to them. The warning were right, your code was invalid.






            share|improve this answer















            You have undefined behaviour. You use the value of a before initialization. If you want your program to be valid, initialize your variable before using it.



            struct test 
            int a;

            test(): a(0) // Effectively return the value of a,
            // which is 0 at this point.
            // ~~~~~~~v~~~~
            a = [this] return fun(); ();


            int fun()

            return a;

            ;

            int main()

            auto t = test();
            std::cout << t.a << 'n';
            return 0;



            Your compilers even warned you about your code. Listen to them. The warning were right, your code was invalid.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Mar 8 at 20:57

























            answered Mar 8 at 20:53









            Guillaume RacicotGuillaume Racicot

            16.6k53872




            16.6k53872












            • Clang did not warn me about this. Only gcc at optimazation level one warned me.

              – user3457151
              Mar 8 at 20:57












            • @user3457151 yes. Compilers are not required to find all possible warnings one would expect. They're only there to help you if the compiler find something odd.

              – Guillaume Racicot
              Mar 8 at 20:58


















            • Clang did not warn me about this. Only gcc at optimazation level one warned me.

              – user3457151
              Mar 8 at 20:57












            • @user3457151 yes. Compilers are not required to find all possible warnings one would expect. They're only there to help you if the compiler find something odd.

              – Guillaume Racicot
              Mar 8 at 20:58

















            Clang did not warn me about this. Only gcc at optimazation level one warned me.

            – user3457151
            Mar 8 at 20:57






            Clang did not warn me about this. Only gcc at optimazation level one warned me.

            – user3457151
            Mar 8 at 20:57














            @user3457151 yes. Compilers are not required to find all possible warnings one would expect. They're only there to help you if the compiler find something odd.

            – Guillaume Racicot
            Mar 8 at 20:58






            @user3457151 yes. Compilers are not required to find all possible warnings one would expect. They're only there to help you if the compiler find something odd.

            – Guillaume Racicot
            Mar 8 at 20:58


















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55070740%2fusage-before-initialization-of-const-member-is-this-expected-bahviour-of-gcc-an%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

            Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

            Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved