public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug analyzer/95039] New: GCC 10 Analyzer and ‘‘result_decl’ not supported by dump_expr
@ 2020-05-10 17:59 noloader at gmail dot com
  0 siblings, 0 replies; only message in thread
From: noloader at gmail dot com @ 2020-05-10 17:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95039

            Bug ID: 95039
           Summary: GCC 10 Analyzer and ‘‘result_decl’ not supported by
                    dump_expr
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: noloader at gmail dot com
  Target Milestone: ---

Created attachment 48498
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48498&action=edit
Preprocessed source file ecp.ii

Hi Everyone,

I'm trying out the analyzer on a C++ project. I'm working on Fedora 32 with GCC
10.

  $ gcc --version
  gcc (GCC) 10.0.1 20200430 (Red Hat 10.0.1-0.14)

Here's what I am seeing:

‘std::_Vector_base<CryptoPP::WindowSlider,
std::allocator<CryptoPP::WindowSlider> >::_M_allocate’
           |......
           |  346 |  return __n != 0 ? _Tr::allocate(_M_impl, __n) : pointer();
           |      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           |      |                  |                                       |
           |      |                  |                                      
(5) ...to here
           |      |                  |                                      
(6) ‘‘result_decl’ not supported by dump_expr<expression error>’ is NULL
           |      |                  (4) following ‘false’ branch (when ‘__n ==
0’)...

The odd thing (to me) is, std::allocate related functions seem to be analyzed
as returning NULL. But in C++ a failed allocation throws, it does not return
NULL.

It is fairly easy to duplicate with live code. Unfortunately, I am not sure
what is needed for a reproducer based on the error message. (I tired to
duplicate with a toy example using std::vector, but no joy). It can be
duplicated with live code using:

  $ git clone https://github.com/weidai11/cryptopp.git
  $ cd cryptopp
  $ CXXFLAGS="-DNDEBUG -g2 -O3 -fanalyzer -save-temps" make ecp.o
  ...
  <Lots of Analyzer output>

Attached is the output with a -save-temps.

This may be related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94034.

==========

In file included from ecp.h:10,
                 from ecp.cpp:7:
integer.h: In static member function ‘static void std::_Destroy_aux<<anonymous>
>::__destroy(_ForwardIterator, _ForwardIterator) [with _ForwardIterator =
CryptoPP::WindowSlider*; bool <anonymous> = false]’:
integer.h:49:20: warning: dereference of NULL ‘__first’ [CWE-690]
[-Wanalyzer-null-dereference]
   49 | class CRYPTOPP_DLL Integer : private InitializeInteger, public
ASN1Object
      |                    ^~~~~~~
  ‘std::vector<_Tp, _Alloc>::pointer std::vector<_Tp,
_Alloc>::_M_allocate_and_copy(std::vector<_Tp, _Alloc>::size_type,
_ForwardIterator, _ForwardIterator) [with _ForwardIterator = const
CryptoPP::WindowSlider*; _Tp = CryptoPP::WindowSlider; _Alloc =
std::allocator<CryptoPP::WindowSlider>]’: events 1-2
    |
    |/usr/include/c++/10/bits/stl_vector.h:1508:2:
    | 1508 |  _M_allocate_and_copy(size_type __n,
    |      |  ^~~~~~~~~~~~~~~~~~~~
    |      |  |
    |      |  (1) entry to
‘std::vector<CryptoPP::WindowSlider>::_M_allocate_and_copy<const
CryptoPP::WindowSlider*>’
    |......
    | 1511 |    pointer __result = this->_M_allocate(__n);
    |      |                       ~~~~~~~~~~~~~~~~~~~~~~
    |      |                                        |
    |      |                                        (2) calling
‘std::_Vector_base<CryptoPP::WindowSlider,
std::allocator<CryptoPP::WindowSlider> >::_M_allocate’ from
‘std::vector<CryptoPP::WindowSlider>::_M_allocate_and_copy<const
CryptoPP::WindowSlider*>’
    |
    +--> ‘std::_Vector_base<_Tp, _Alloc>::pointer std::_Vector_base<_Tp,
_Alloc>::_M_allocate(std::size_t) [with _Tp = CryptoPP::WindowSlider; _Alloc =
std::allocator<CryptoPP::WindowSlider>]’: events 3-6
           |
           |  343 |       _M_allocate(size_t __n)
           |      |       ^~~~~~~~~~~
           |      |       |
           |      |       (3) entry to
‘std::_Vector_base<CryptoPP::WindowSlider,
std::allocator<CryptoPP::WindowSlider> >::_M_allocate’
           |......
           |  346 |  return __n != 0 ? _Tr::allocate(_M_impl, __n) : pointer();
           |      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           |      |                  |                                       |
           |      |                  |                                      
(5) ...to here
           |      |                  |                                      
(6) ‘‘result_decl’ not supported by dump_expr<expression error>’ is NULL
           |      |                  (4) following ‘false’ branch (when ‘__n ==
0’)...
           |
    <------+
    |
  ‘std::vector<_Tp, _Alloc>::pointer std::vector<_Tp,
_Alloc>::_M_allocate_and_copy(std::vector<_Tp, _Alloc>::size_type,
_ForwardIterator, _ForwardIterator) [with _ForwardIterator = const
CryptoPP::WindowSlider*; _Tp = CryptoPP::WindowSlider; _Alloc =
std::allocator<CryptoPP::WindowSlider>]’: event 7
    |
    | 1511 |    pointer __result = this->_M_allocate(__n);
    |      |                       ~~~~~~~~~~~~~~~~~^~~~~
    |      |                                        |
    |      |                                        (7) return of NULL to
‘std::vector<CryptoPP::WindowSlider>::_M_allocate_and_copy<const
CryptoPP::WindowSlider*>’ from ‘std::_Vector_base<CryptoPP::WindowSlider,
std::allocator<CryptoPP::WindowSlider> >::_M_allocate’
    |
  ‘std::vector<_Tp, _Alloc>::pointer std::vector<_Tp,
_Alloc>::_M_allocate_and_copy(std::vector<_Tp, _Alloc>::size_type,
_ForwardIterator, _ForwardIterator) [with _ForwardIterator = const
CryptoPP::WindowSlider*; _Tp = CryptoPP::WindowSlider; _Alloc =
std::allocator<CryptoPP::WindowSlider>]’: event 8
    |
    |/usr/include/c++/10/bits/stl_uninitialized.h:150:15:
    |  147 |       return std::__uninitialized_copy<__is_trivial(_ValueType1)
    |      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |  148 |            && __is_trivial(_ValueType2)
    |      |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |  149 |            && __assignable>::
    |      |            ~~~~~~~~~~~~~~~~~~
    |  150 |  __uninit_copy(__first, __last, __result);
    |      |  ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |               |
    |      |               (8) calling
‘std::__uninitialized_copy<false>::__uninit_copy<const CryptoPP::WindowSlider*,
CryptoPP::WindowSlider*>’ from
‘std::vector<CryptoPP::WindowSlider>::_M_allocate_and_copy<const
CryptoPP::WindowSlider*>’
    |
    +--> ‘static _ForwardIterator
std::__uninitialized_copy<_TrivialValueTypes>::__uninit_copy(_InputIterator,
_InputIterator, _ForwardIterator) [with _InputIterator = const
CryptoPP::WindowSlider*; _ForwardIterator = CryptoPP::WindowSlider*; bool
_TrivialValueTypes = false]’: events 9-10
           |
           |   84 |         __uninit_copy(_InputIterator __first,
_InputIterator __last,
           |      |         ^~~~~~~~~~~~~
           |      |         |
           |      |         (9) entry to
‘std::__uninitialized_copy<false>::__uninit_copy<const CryptoPP::WindowSlider*,
CryptoPP::WindowSlider*>’
           |......
           |   90 |        for (; __first != __last; ++__first, (void)++__cur)
           |      |               ~~~~~~~~~~~~~~~~~
           |      |                       |
           |      |                       (10) following ‘false’ branch (when
‘__first != __last’)...
           |
         ‘static _ForwardIterator
std::__uninitialized_copy<_TrivialValueTypes>::__uninit_copy(_InputIterator,
_InputIterator, _ForwardIterator) [with _InputIterator = const
CryptoPP::WindowSlider*; _ForwardIterator = CryptoPP::WindowSlider*; bool
_TrivialValueTypes = false]’: event 11
           |
           |/usr/include/c++/10/bits/move.h:49:5:
           |   49 |     __addressof(_Tp& __r) _GLIBCXX_NOEXCEPT
           |      |     ^~~~~~~~~~~
           |      |     |
           |      |     (11) ...to here
           |
         ‘static _ForwardIterator
std::__uninitialized_copy<_TrivialValueTypes>::__uninit_copy(_InputIterator,
_InputIterator, _ForwardIterator) [with _InputIterator = const
CryptoPP::WindowSlider*; _ForwardIterator = CryptoPP::WindowSlider*; bool
_TrivialValueTypes = false]’: event 12
           |
           |/usr/include/c++/10/bits/stl_uninitialized.h:90:23:
           |   90 |        for (; __first != __last; ++__first, (void)++__cur)
           |      |               ~~~~~~~~^~~~~~~~~
           |      |                       |
           |      |                       (12) following ‘false’ branch (when
‘__first != __last’)...
           |
         ‘static _ForwardIterator
std::__uninitialized_copy<_TrivialValueTypes>::__uninit_copy(_InputIterator,
_InputIterator, _ForwardIterator) [with _InputIterator = const
CryptoPP::WindowSlider*; _ForwardIterator = CryptoPP::WindowSlider*; bool
_TrivialValueTypes = false]’: event 13
           |
           |/usr/include/c++/10/bits/move.h:49:5:
           |   49 |     __addressof(_Tp& __r) _GLIBCXX_NOEXCEPT
           |      |     ^~~~~~~~~~~
           |      |     |
           |      |     (13) ...to here
           |
         ‘static _ForwardIterator
std::__uninitialized_copy<_TrivialValueTypes>::__uninit_copy(_InputIterator,
_InputIterator, _ForwardIterator) [with _InputIterator = const
CryptoPP::WindowSlider*; _ForwardIterator = CryptoPP::WindowSlider*; bool
_TrivialValueTypes = false]’: event 14
           |
           |/usr/include/c++/10/bits/stl_construct.h:185:11:
           |  184 |      
std::_Destroy_aux<__has_trivial_destructor(_Value_type)>::
           |      |      
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           |  185 |  __destroy(__first, __last);
           |      |  ~~~~~~~~~^~~~~~~~~~~~~~~~~
           |      |           |
           |      |           (14) calling
‘std::_Destroy_aux<false>::__destroy<CryptoPP::WindowSlider*>’ from
‘std::__uninitialized_copy<false>::__uninit_copy<const CryptoPP::WindowSlider*,
CryptoPP::WindowSlider*>’
           |
           +--> ‘static void std::_Destroy_aux<<anonymous>
>::__destroy(_ForwardIterator, _ForwardIterator) [with _ForwardIterator =
CryptoPP::WindowSlider*; bool <anonymous> = false]’: events 15-16
                  |
                  |  149 |  __destroy(_ForwardIterator __first,
_ForwardIterator __last)
                  |      |  ^~~~~~~~~
                  |      |  |
                  |      |  (15) entry to
‘std::_Destroy_aux<false>::__destroy<CryptoPP::WindowSlider*>’
                  |  150 |  {
                  |  151 |    for (; __first != __last; ++__first)
                  |      |           ~~~~~~~~~~~~~~~~~
                  |      |                   |
                  |      |                   (16) following ‘false’ branch
(when ‘__first != __last’)...
                  |
                ‘static void std::_Destroy_aux<<anonymous>
>::__destroy(_ForwardIterator, _ForwardIterator) [with _ForwardIterator =
CryptoPP::WindowSlider*; bool <anonymous> = false]’: event 17
                  |
                  |/usr/include/c++/10/bits/move.h:49:5:
                  |   49 |     __addressof(_Tp& __r) _GLIBCXX_NOEXCEPT
                  |      |     ^~~~~~~~~~~
                  |      |     |
                  |      |     (17) ...to here
                  |
                ‘static void std::_Destroy_aux<<anonymous>
>::__destroy(_ForwardIterator, _ForwardIterator) [with _ForwardIterator =
CryptoPP::WindowSlider*; bool <anonymous> = false]’: event 18
                  |
                  |integer.h:49:20:
                  |   49 | class CRYPTOPP_DLL Integer : private
InitializeInteger, public ASN1Object
                  |      |                    ^~~~~~~
                  |      |                    |
                  |      |                    (18) calling
‘CryptoPP::SecBlock<long unsigned int, CryptoPP::AllocatorWithCleanup<long
unsigned int, true> >::~SecBlock’ from
‘std::_Destroy_aux<false>::__destroy<CryptoPP::WindowSlider*>’
                  |
                  +--> ‘CryptoPP::SecBlock<T, A>::~SecBlock() [with T = long
unsigned int; A = CryptoPP::AllocatorWithCleanup<long unsigned int, true>]’:
event 19
                         |
                         |secblock.h:772:2:
                         |  772 |  ~SecBlock()
                         |      |  ^
                         |      |  |
                         |      |  (19) entry to ‘CryptoPP::SecBlock<long
unsigned int, CryptoPP::AllocatorWithCleanup<long unsigned int, true>
>::~SecBlock’
                         |
                       ‘CryptoPP::SecBlock<T, A>::~SecBlock() [with T = long
unsigned int; A = CryptoPP::AllocatorWithCleanup<long unsigned int, true>]’:
event 20
                         |
                         |misc.h:633:15:
                         |  633 |  return b < a ? b : a;
                         |      |         ~~~~~~^~~~~~~
                         |      |               |
                         |      |               (20) following ‘true’ branch...
                         |
                       ‘CryptoPP::SecBlock<T, A>::~SecBlock() [with T = long
unsigned int; A = CryptoPP::AllocatorWithCleanup<long unsigned int, true>]’:
events 21-23
                         |
                         |secblock.h:773:36:
                         |  233 |   if (ptr)
                         |      |   ~~
                         |      |   |
                         |      |   (22) following ‘false’ branch...
                         |......
                         |  773 |   {m_alloc.deallocate(m_ptr, STDMIN(m_size,
m_mark));}
                         |      |   
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
                         |      |                      |             |
                         |      |                      |             (21) ...to
here
                         |      |                      (23) ...to here
                         |
                  <------+
                  |
                ‘static void std::_Destroy_aux<<anonymous>
>::__destroy(_ForwardIterator, _ForwardIterator) [with _ForwardIterator =
CryptoPP::WindowSlider*; bool <anonymous> = false]’: events 24-25
                  |
                  |integer.h:49:20:
                  |   49 | class CRYPTOPP_DLL Integer : private
InitializeInteger, public ASN1Object
                  |      |                    ^~~~~~~
                  |      |                    |
                  |      |                    (24) returning to
‘std::_Destroy_aux<false>::__destroy<CryptoPP::WindowSlider*>’ from
‘CryptoPP::SecBlock<long unsigned int, CryptoPP::AllocatorWithCleanup<long
unsigned int, true> >::~SecBlock’
                  |      |                    (25) dereference of NULL
‘__first’
                  |

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-05-10 17:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-10 17:59 [Bug analyzer/95039] New: GCC 10 Analyzer and ‘‘result_decl’ not supported by dump_expr noloader at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).