[omniORB] G++ 12.2 complains with stringop-overflow warning

Duncan Grisby duncan at grisby.org
Mon Jun 5 11:04:42 UTC 2023


On Thu, 2023-06-01 at 19:59 +0200, Thomas Braun via omniORB-list wrote:


> one of the newer gcc versions complains about some omniORB code.
> I'm attaching the files needed for reproduction.

[...]
> In file included from /usr/include/omniORB4/omniInternal.h:44,
>                  from /usr/include/omniORB4/CORBA.h:63,
>                  from test.cpp:1:
> In member function ‘void _CORBA_Sequence<T>::copybuffer(_CORBA_ULong)
> [with T = unsigned char]’,
>     inlined from ‘void _CORBA_Sequence<T>::length(_CORBA_ULong) [with
> T
> = unsigned char]’ at /usr/include/omniORB4/seqTemplatedecls.h:59:12,
>     inlined from ‘int main(int, char**)’ at test.cpp:8:10:
> /usr/include/omniORB4/seqTemplatedecls.h:211:17: error: writing 8
> bytes
> into a region of size 1 [-Werror=stringop-overflow=]
>   211 |       newbuf[i] = pd_buf[i];
>       |       ~~~~~~~~~~^~~~~~~~~

I have seen those complaints too. gcc is wrong. I don't know why it
thinks the region has size 1, because it plainly does not. There is no
error in the code.

[...]
> In addition I do see some mixing of unsigned long and _CORBA_ULong in
> seqTemplatedecls.h/copybuffer which I find confusing as IIRC you
> can't interchangebly use these types in general.

That is a historical accident, but it does no harm because unsigned
long is always at least as big as _CORBA_ULong, and the way the values
are used, they cannot overflow. 

Regards,

Duncan.


-- 
 -- Duncan Grisby --
  -- duncan at grisby.org --
   -- http://www.grisby.org --




More information about the omniORB-list mailing list