Re: Help diagnosing a GCC 10.2 problem : error: 'removed_return.213' may be used uninitialized in this function

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

 



Hi all, after some work I was able to extract a reproducible case:

This is the code:

#include <ostream>

extern std::ostream* the_dout;

namespace Debug
{
    bool IsEnabled();
}

class MyClass
{
    MyClass();
    ~MyClass();
    int value;
};

MyClass:: MyClass() : value(0)
{
    if (Debug::IsEnabled()) (*the_dout) << value << std::endl;
}

MyClass::~MyClass()
{
    Debug::IsEnabled() && (*the_dout) << value << std::endl;
}

This is the command line:

g++ -c -fnon-call-exceptions -Wmaybe-uninitialized -O2 gcc10bug.cpp

And this is the error:

gcc10bug.cpp: In destructor 'MyClass::~MyClass()':
gcc10bug.cpp:24:56: warning: 'removed_return.24' may be used uninitialized in this function [-Wmaybe-uninitialized]
   24 |     Debug::IsEnabled() && (*the_dout) << value << std::endl;
      |                                                        ^~~~

A few notes:

1. the ^~~~ is pointing at endl
2. the almost similar code in the constructor does not error out
2. there is no error if -fnon-call-exceptions is removed

Nick



On Wednesday, January 6, 2021, 11:35:01 AM PST, Segher Boessenkool <segher@xxxxxxxxxxxxxxxxxxx> wrote: 





On Wed, Jan 06, 2021 at 06:25:32PM +0000, Nick Savoiu via Gcc-help wrote:

> Hi Martin, the program crashes, not GCC.
> 
> My code does not contain any 'removed_return'. I suspect that it's a GCC thing so it would probably not appear in a -E output.


It's an artificial name GCC makes up (in IPA)


Segher





[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