Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-20338

gcc-toolset-12-gcc: g++ shows a warning about uninitialized memory

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Normal Normal
    • rhel-8.10
    • rhel-8.9.0
    • gcc-toolset-12-gcc
    • None
    • None
    • None
    • rhel-sst-pt-gcc
    • ssg_platform_tools
    • 1
    • False
    • Hide

      None

      Show
      None
    • None
    • None
    • None
    • None
    • None

      When using g++ from devtoolset-12-gcc-c++ to compile a test file, a warning about uninitialized memory is shown. This warning is not present on devtoolset-11-gcc-c++.

      ~~~
      $ cat foo.cpp
      #include <string>

      struct Foo
      {
      static Foo OK;

      ~Foo() noexcept( false ) {}
      };

      Foo Foo::OK;

      Foo run()
      {
      if ( 1 == 0 )

      { return Foo::OK; }

      switch ( 1 )
      {
      case 1:
      {
      try

      { throw( 2 ); }

      catch ( int ex )
      {
      }
      }
      }

      std::string text;

      return Foo::OK;
      }
      ~~~

      When using devtoolset-11-gcc-c+, it compiles without warnings. When using devtoolset-12-gcc-c+, the following is shown:

      ~~~
      [root@r79 ~]# source /opt/rh/devtoolset-12/enable
      [root@r79 ~]# g++ -Wall -c src/foo.cpp -o obj/foo.o
      src/foo.cpp: In function ‘Foo run()’:
      src/foo.cpp:26:10: warning: ‘<anonymous>’ is used uninitialized [-Wuninitialized]
      26 | }

      ^
      src/foo.cpp:16:19: note: ‘<anonymous>’ was declared here
      16
      return Foo::OK;
      ^~
      [root@r79 ~]#
      ~~~

              mpolacek@redhat.com Marek Polacek
              rhn-support-jsantos Juan Santos
              Marek Polacek Marek Polacek
              Vaclav Kadlcik Vaclav Kadlcik
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: