https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84289
Bug ID: 84289 Summary: warning : variabile unitialized, emit right check only with O(1,2,3) optimisation level (in try/catch) Product: gcc Version: 5.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: daffra.claudio at gmail dot com Target Milestone: --- Created attachment 43376 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43376&action=edit file to reproduce error i use this flags to compile program below : -Wall -Wextra -pedantic-errors -std=c++11 g++ gives me NO warning, indeed with -Wall -Wextra -pedantic-errors -std=c++11 -O3 g++ emit right warning in this example g++ emit correct warning only when is active optimisation level (123), but not with optimisation 0 or in other way #include <iostream> #include <string> #include <stdexcept> uint64_t StringToInteger ( std::string str, int _base ) { uint64_t n; try { n = std::stoull ( str,nullptr,_base ); } catch ( std::invalid_argument ) { std::cout << "error" ; } return n ; } int main ( void ) { std::cout << StringToInteger ( "123",10 ) ; return 0 ; } in this other example #include <iostream> #include <string> #include <stdexcept> uint64_t StringToInteger ( std::string str, int _base ) { uint64_t n; return n ; } int main ( void ) { std::cout << StringToInteger ( "123",10 ) ; return 0 ; } g++ emit warning ! with or without optimisation flags, rightly !