public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110283] New: Bogus Warray-bounds
@ 2023-06-16 12:18 pilarlatiesa at gmail dot com
  2023-06-16 12:19 ` [Bug c++/110283] " pilarlatiesa at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: pilarlatiesa at gmail dot com @ 2023-06-16 12:18 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110283
           Summary: Bogus Warray-bounds
           Product: gcc
           Version: 13.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pilarlatiesa at gmail dot com
  Target Milestone: ---

$ ~/gcc-13/bin/g++ -v
Usando especificaciones internas.
COLLECT_GCC=~/gcc-13/bin/g++
COLLECT_LTO_WRAPPER=/home/pililatiesa/gcc-13/libexec/gcc/x86_64-pc-linux-gnu/13.1.0/lto-wrapper
Objetivo: x86_64-pc-linux-gnu
Configurado con: ../gcc-13.1.0/configure --enable-languages=c,c++
--disable-multilib --prefix=/home/pililatiesa/gcc-13/
Modelo de hilos: posix
Algoritmos de compresión LTO admitidos: zlib
gcc versión 13.1.0 (GCC)


$ ~/gcc-13/bin/g++ -std=c++23 -Wall -O3 -c ElemBase.ii 
En el fichero incluido desde ../../MEF/ElemBase.h:11,
                 desde ../ElemBase.cpp:2:
In member function ‘constexpr const std::array<_Tp, _Nm>::value_type&
std::array<_Tp, _Nm>::operator[](size_type) const [with _Tp = const TNodo<3>*;
long unsigned int _Nm = 2]’,
    inlined from ‘const TNodo<TElemTraits<TElem>::Ngdl>&
TElemBase<TElem>::Nodo(int) const [with TElem = TElemViga]’ at
../../MEF/ElemBase.h:64:25,
    inlined from ‘void TElemBase<TElem>::CalcCCTerm(TTripletVec&) const [with
TElem = TElemViga]’ at ../ElemBase.cpp:10:21:
/home/pililatiesa/gcc-13/include/c++/13.1.0/array:213:17: aviso: el subíndice 2
de la matriz está por encima de los límites de matriz de
‘std::__array_traits<const TNodo<3>*, 2>::_Type’ {aka ‘const TNodo<3>* const
[2]’} [-Warray-bounds=]
/home/pililatiesa/gcc-13/include/c++/13.1.0/array: In member function ‘void
TElemBase<TElem>::CalcCCTerm(TTripletVec&) const [with TElem = TElemViga]’:
/home/pililatiesa/gcc-13/include/c++/13.1.0/array:109:48: nota: while
referencing ‘std::array<const TNodo<3>*, 2>::_M_elems’

I couldn't get rid of the eigen dependency, sorry.

It only happens with O3.

It appears that it is only a bogus warning, but I don't know if wrong code is
actually generated.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/110283] Bogus Warray-bounds
  2023-06-16 12:18 [Bug c++/110283] New: Bogus Warray-bounds pilarlatiesa at gmail dot com
@ 2023-06-16 12:19 ` pilarlatiesa at gmail dot com
  2023-06-16 21:06 ` [Bug tree-optimization/110283] " pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pilarlatiesa at gmail dot com @ 2023-06-16 12:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Pilar Latiesa <pilarlatiesa at gmail dot com> ---
Created attachment 55345
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55345&action=edit
preprocessed code

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/110283] Bogus Warray-bounds
  2023-06-16 12:18 [Bug c++/110283] New: Bogus Warray-bounds pilarlatiesa at gmail dot com
  2023-06-16 12:19 ` [Bug c++/110283] " pilarlatiesa at gmail dot com
@ 2023-06-16 21:06 ` pinskia at gcc dot gnu.org
  2023-06-22 22:46 ` c_antonio_sanchez at msn dot com
  2023-06-22 22:52 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-16 21:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
As an aside, Eigen has some maybe wrong code in it:
```
# 55 "../../eigen-3.3.4/Eigen/src/Core/arch/SSE/PacketMath.h" 3 4
typedef __m128 Packet4f;
typedef __m128i Packet4i;
typedef __m128d Packet2d;


template<> struct is_arithmetic<__m128> { enum { value = true }; };
template<> struct is_arithmetic<__m128i> { enum { value = true }; };
template<> struct is_arithmetic<__m128d> { enum { value = true }; };
...
template<> struct unpacket_traits<Packet4f> { typedef float type; enum {size=4,
alignment=Aligned16}; typedef Packet4f half; };
template<> struct unpacket_traits<Packet2d> { typedef double type; enum
{size=2, alignment=Aligned16}; typedef Packet2d half; };
template<> struct unpacket_traits<Packet4i> { typedef int type; enum {size=4,
alignment=Aligned16}; typedef Packet4i half; };
```
Because __m128/__m128i/__m128d are all declared as may_alias but the template
will lose that attribute.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/110283] Bogus Warray-bounds
  2023-06-16 12:18 [Bug c++/110283] New: Bogus Warray-bounds pilarlatiesa at gmail dot com
  2023-06-16 12:19 ` [Bug c++/110283] " pilarlatiesa at gmail dot com
  2023-06-16 21:06 ` [Bug tree-optimization/110283] " pinskia at gcc dot gnu.org
@ 2023-06-22 22:46 ` c_antonio_sanchez at msn dot com
  2023-06-22 22:52 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: c_antonio_sanchez at msn dot com @ 2023-06-22 22:46 UTC (permalink / raw)
  To: gcc-bugs

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

Antonio Sanchez <c_antonio_sanchez at msn dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |c_antonio_sanchez at msn dot com

--- Comment #3 from Antonio Sanchez <c_antonio_sanchez at msn dot com> ---
@Andrew Pinsky can you elaborate on what's potentially wrong in the Eigen code?

The template argument will ignore the `may_alias` attribute, but the `typedef`s
do not, so `Packet4f` and `unpacket_traits<Packet4f>::half` are still marked as
`may_alias` and do allow aliasing without strict-aliasing warnings.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/110283] Bogus Warray-bounds
  2023-06-16 12:18 [Bug c++/110283] New: Bogus Warray-bounds pilarlatiesa at gmail dot com
                   ` (2 preceding siblings ...)
  2023-06-22 22:46 ` c_antonio_sanchez at msn dot com
@ 2023-06-22 22:52 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-22 22:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Antonio Sanchez from comment #3)
> @Andrew Pinsky can you elaborate on what's potentially wrong in the Eigen
> code?
> 
> The template argument will ignore the `may_alias` attribute, but the
> `typedef`s do not, so `Packet4f` and `unpacket_traits<Packet4f>::half` are
> still marked as `may_alias` and do allow aliasing without strict-aliasing
> warnings.

As I said potentially wrong because of the template arguments ignorning the
attributes and I didn't look further into the code to see if Eigen used that
template argument in anyway except for matching.


But that is a different issue overall.

Anyways the warning here is complex due to how complex the code Eigen causes to
be inlined and someone will have to figure out why the warning is happening if
it is a true bug or just warning about dead code or something GCC could not
figure out is not out of bounds.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-06-22 22:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-16 12:18 [Bug c++/110283] New: Bogus Warray-bounds pilarlatiesa at gmail dot com
2023-06-16 12:19 ` [Bug c++/110283] " pilarlatiesa at gmail dot com
2023-06-16 21:06 ` [Bug tree-optimization/110283] " pinskia at gcc dot gnu.org
2023-06-22 22:46 ` c_antonio_sanchez at msn dot com
2023-06-22 22:52 ` pinskia at gcc dot gnu.org

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).