[Bug libstdc++/105681] libstdc++-v3 fails to build on msp430

2022-05-26 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105681

--- Comment #10 from CVS Commits  ---
The master branch has been updated by Jonathan Wakely :

https://gcc.gnu.org/g:367740bf6d3a6627798b3955e5d85efc7549ef50

commit r13-787-g367740bf6d3a6627798b3955e5d85efc7549ef50
Author: Jonathan Wakely 
Date:   Thu May 26 21:32:55 2022 +0100

libstdc++: Fix narrowing conversions for 16-bit size_t [PR105681]

On a 16-bit target such as msp430 we get errors about narrowing long
values to size_t, which is only 16-bit. When --enable-libstdcxx-pch is
used the  header breaks the build because of these
narrowing errors.

libstdc++-v3/ChangeLog:

PR libstdc++/105681
*
include/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp:
Limit ga_sizes array to values that fit in size_t.
* include/ext/random [__SIZE_WIDTH < 32] (sfmt86243)
(sfmt86243_64, sfmt132049, sfmt132049_64, sfmt216091)
(sfmt216091_64): Do not declare.

[Bug libstdc++/105681] libstdc++-v3 fails to build on msp430

2022-05-26 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105681

--- Comment #9 from Jonathan Wakely  ---
Ah, and I didn't see this when building for msp430 because I used
--disable-libstdcxx-pch and that means the build doesn't depend on the
 header.

I can now reproduce the build failure, and the patch in comment 6 fixes the
failures in , but then we fail later:

/tmp/msp430/msp430-elf/libstdc++-v3/include/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp:73:32:
error: narrowing conversion of '116731' from 'long unsigned int' to
'std::size_t' {aka 'unsigned int'} [-Wnarrowing]
   73 |   /* 14*/  116731ul,
  |^~~~

Those are also non-standard extensions. Maybe we should just not install the
precompiled header for  on 16-bit targets.

As a workaround until I fix all the problems, you can use
--disable-libstdcxx-pch

[Bug libstdc++/105681] libstdc++-v3 fails to build on msp430

2022-05-26 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105681

--- Comment #8 from Jonathan Wakely  ---
And it was indeed something I asked for, see r12-2355

c++: Don't hide narrowing errors in system headers

Jonathan pointed me at this issue where

  constexpr unsigned f() { constexpr int n = -1; return unsigned{n}; }

is accepted in system headers, despite the narrowing conversion from
a constant.  I suspect that whereas narrowing warnings should be
disabled, ill-formed narrowing of constants should be a hard error
(which can still be disabled by -Wno-narrowing).

[Bug libstdc++/105681] libstdc++-v3 fails to build on msp430

2022-05-26 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105681

--- Comment #7 from Jonathan Wakely  ---
(In reply to Richard Biener from comment #4)
> possibly the system header diagnostic changes?

Yes, the narrowing check here was PR c++/57891 which was fixed for GCC 9. But
it was still allowed in system headers until GCC 12.

[Bug libstdc++/105681] libstdc++-v3 fails to build on msp430

2022-05-26 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105681

Jonathan Wakely  changed:

   What|Removed |Added

 Ever confirmed|0   |1
   Target Milestone|--- |12.2
 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2022-05-26
   Assignee|unassigned at gcc dot gnu.org  |redi at gcc dot gnu.org

--- Comment #6 from Jonathan Wakely  ---
I think the compiler might have got stricter about diagnosing narrowing
conversions in non-type template arguments (I think I even reported a bug
saying it should do that!)

The problem is that size_t is a 16-bit unsigned int, so too small for the
values we use in the specializations:

  template
class simd_fast_mersenne_twister_engine

// ...

  typedef simd_fast_mersenne_twister_engine
sfmt86243;

We could change the size_t there to be a type with at least 32 bits to make it
work, but I think the right fix is to simply not defined those typedefs that
don't fit in 16 bits:

--- a/libstdc++-v3/include/ext/random
+++ b/libstdc++-v3/include/ext/random
@@ -346,6 +346,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
0xa3ac4000U, 0xecc1327aU>
 sfmt44497_64;

+#if __SIZE_WIDTH__ >= 32

   typedef simd_fast_mersenne_twister_engine
 sfmt216091_64;
+#endif // __SIZE_WIDTH__ >= 32

 #endif // __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__


Everything in  is a non-standard extension, so we're under no
obligation to provide any of it for standard conformance.

[Bug libstdc++/105681] libstdc++-v3 fails to build on msp430

2022-05-26 Thread beagleboard at davidjohnsummers dot uk via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105681

--- Comment #5 from David Summers  ---
Yes I can confirm that going back to gcc-11.2.0 - and it works again, that
being the only change. It explains how I got the headers, on my first build I
used 11.2.0; whilst it was building saw that gcc-12 was available, so
downloaded for a second pass (always like to do two passes - to make sure that
everything knows what else is set up).

So problem is in gcc-12

[Bug libstdc++/105681] libstdc++-v3 fails to build on msp430

2022-05-23 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105681

--- Comment #4 from Richard Biener  ---
possibly the system header diagnostic changes?

[Bug libstdc++/105681] libstdc++-v3 fails to build on msp430

2022-05-22 Thread mikpelinux at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105681

Mikael Pettersson  changed:

   What|Removed |Added

 CC||mikpelinux at gmail dot com

--- Comment #3 from Mikael Pettersson  ---
I can reproduce in a cross to --target=msp430-unknown-elf
--enable-languages=c,c++ with binutils-2.38 and newlib-4.2.0.20211231.
gcc-11.3.0 builds fine, but gcc-12.1.0 build fails with

In file included from
/mnt/scratch/cross/sources/gcc-12.1.0/libstdc++-v3/include/precompiled/extc++.h:61:
/mnt/scratch/cross/objdir-gcc/msp430-unknown-elf/libstdc++-v3/include/ext/random:355:69:
error: narrowing conversion of '86243' from 'long int' to 'unsigned int'
[-Wnarrowing]
  355 | 0xU, 0xe9528d85U>
  | ^
(several more)

and

In file included from
/mnt/scratch/cross/objdir-gcc/msp430-unknown-elf/libstdc++-v3/include/ext/pb_ds/hash_policy.hpp:475,
 from
/mnt/scratch/cross/objdir-gcc/msp430-unknown-elf/libstdc++-v3/include/ext/pb_ds/detail/standard_policies.hpp:45,
 from
/mnt/scratch/cross/objdir-gcc/msp430-unknown-elf/libstdc++-v3/include/ext/pb_ds/assoc_container.hpp:47,
 from
/mnt/scratch/cross/sources/gcc-12.1.0/libstdc++-v3/include/precompiled/extc++.h:72:
/mnt/scratch/cross/objdir-gcc/msp430-unknown-elf/libstdc++-v3/include/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp:73:32:
error: narrowing conversion of '116731' from 'long unsigned int' to
'std::size_t' {aka 'unsigned int'} [-Wnarrowing]
   73 |   /* 14*/  116731ul,
  |^~~~
(many more)

[Bug libstdc++/105681] libstdc++-v3 fails to build on msp430

2022-05-22 Thread beagleboard at davidjohnsummers dot uk via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105681

--- Comment #2 from David Summers  ---
I suspect its the newlib includes that trigger the problem. As it I did one
compile, where the configure grabbed the host includes (and 64bit system); and
that compile I think worked fine.

My problem though, as my target is a small 16bit cpu, I need the smallest
library, and newlib nano seems to work well - so that will be the library on
the machine where the code is run ..,

[Bug libstdc++/105681] libstdc++-v3 fails to build on msp430

2022-05-21 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105681

Jonathan Wakely  changed:

   What|Removed |Added

   Keywords||build

--- Comment #1 from Jonathan Wakely  ---
Odd, that isn't new code and last time I built for msp430 I thought it worked
ok. I'll look into it.