[Bug c++/122185] [16 Regression] ICE: in propagate_necessity, at tree-ssa-dce.cc:1148 since r16-610-g3ecca8f3ad7e7f

2025-11-22 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122185

Jakub Jelinek  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #28 from Jakub Jelinek  ---
Fixed.

[Bug c++/122185] [16 Regression] ICE: in propagate_necessity, at tree-ssa-dce.cc:1148 since r16-610-g3ecca8f3ad7e7f

2025-11-22 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122185

--- Comment #27 from GCC Commits  ---
The master branch has been updated by Jakub Jelinek :

https://gcc.gnu.org/g:fb22d7f3b66cfb55673ca2b954f860d28b50

commit r16-5506-gfb22d7f3b66cfb55673ca2b954f860d28b50
Author: Jakub Jelinek 
Date:   Sat Nov 22 12:24:35 2025 +0100

c++: Readd type checks for cp_fold -ffold-simple-inlines foldings
[PR122185]

In GCC15, cp_fold -ffold-simple-inlines code contained
  if (INDIRECT_TYPE_P (TREE_TYPE (x))
  && INDIRECT_TYPE_P (TREE_TYPE (r)))
check around the optimization, but as std::to_underlying has been
added to the set, it got removed.
Now, the check isn't needed when using correct libstdc++-v3 headers,
because the function template types ensure the converted types are sane
(so for most of them both are some kind of REFERENCE_TYPEs, for addressof
one REFERENCE_TYPE and one POINTER_TYPE, for to_underlying one
ENUMERAL_TYPE
and one INTEGRAL_TYPE_P).
But when some fuzzer or user attempts to implement one or more of those
std:: functions and does it wrong (sure, such code is invalid), we can ICE
because build_nop certainly doesn't handle all possible type conversions.

So, the following patch readds the INDIRECT_REF_P && INDIRECT_REF_P check
for everything but to_underlying, for which it checks ENUMERAL_TYPE to
INTEGRAL_TYPE_P.  That way we don't ICE on bogus code.

Though, I wonder about 2 things, whether the CALL_EXPR_ARG in there
shouldn't be also guarded just in case somebody tries to compile
namespace std { int to_underlying (); }; int a = std::to_underlying ();
and also whether this to_underlying folding doesn't behave differently
from the libstdc++-v3 implementation if the enum is
enum A : bool { B, C };
I think -fno-fold-simple-inlines will compile it as != 0, while
the -ffold-simple-inlines code just as a cast.  Sure, enum with underlying
bool can't contain enumerators with values other than 0 and 1, but it is
still 8-bit at least and so what happens with other values?

2025-11-22  Jakub Jelinek  

PR c++/122185
* cp-gimplify.cc (cp_fold) : For
-ffold-simple-inlines
restore check that both types are INDIRECT_TYPE_P, except for
"to_underlying" check that r has ENUMERAL_TYPE and x has
INTEGRAL_TYPE_P.

* g++.dg/cpp1z/pr122185.C: New test.

[Bug c++/122185] [16 Regression] ICE: in propagate_necessity, at tree-ssa-dce.cc:1148 since r16-610-g3ecca8f3ad7e7f

2025-11-21 Thread ville.voutilainen at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122185

--- Comment #26 from Ville Voutilainen  ---
Jakub, the comment you seek to have in that code, so that foolish front-end
critters such as myself understand not to mess with it is, instead of

/* Only fold if the involved types look sane for the corresponding
   calls, build_nop is certainly not appropriate for arbitrary
   type changes on invalid sources.  See PR122185.  */

something along the lines of

/* These type-checks must be performed here, the underlying code
   doesn't perform them. See e.g. PR122185.  */

[Bug c++/122185] [16 Regression] ICE: in propagate_necessity, at tree-ssa-dce.cc:1148 since r16-610-g3ecca8f3ad7e7f

2025-11-21 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122185

Jakub Jelinek  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |jakub at gcc dot gnu.org
 CC||jakub at gcc dot gnu.org

--- Comment #25 from Jakub Jelinek  ---
Created attachment 62873
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62873&action=edit
gcc16-pr122185.patch

You can't provide a valid testcase for this, because it can only ICE on invalid
ones.  In particular the -ffold-simple-inlines code was just assuming standard
conforming std::move, std::forward, std::forward_like, std::addressof,
std::as_const, std::to_underlying and std::__addressof with same behavior as
std::addressof.
The INDIRECT_TYPE_P && INDIRECT_TYPE_P check was actually correct before for
preventing folding (and possibly ICEs or weird stuff) on invalid definitions of
these.  Now, std::to_underlying doesn't satisfy that and guess that is why it
was removed, in that case it wants to convert ENUMERAL_TYPE to INTEGRAL_TYPE_P.
So, this patch checks that too.

[Bug c++/122185] [16 Regression] ICE: in propagate_necessity, at tree-ssa-dce.cc:1148 since r16-610-g3ecca8f3ad7e7f

2025-10-18 Thread zsojka at seznam dot cz via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122185

--- Comment #19 from Zdenek Sojka  ---
Created attachment 62523
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62523&action=edit
reduced (?) signature.cpp, including system headers, crashing at a different
place

This is probably the best I can provide:
$ x86_64-pc-linux-gnu-gcc -fno-thread-jumps -O -fprofile-use -std=gnu++20
signature4.cpp -w
signature4.cpp: In member function 'ValueType
nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT0::basic_json<
, , 
>::get_impl(int) [with ValueType = std::__cxx11::basic_string; typename
std::enable_if, ,  >,
ValueType>::value, int>::type  = 0; StringType =
std::__cxx11::basic_string; BooleanType = bool; CustomBaseClass = void]':
signature4.cpp:58:163: error: invalid conversion in return statement
   58 | :enable_if_t<   detail::has_from_json< basic_json_t, ValueType
>::value, int > = 0 >   ValueType get_impl(int) noexcept(noexcept(  
from_json(std::declval< basic_json_t >, std::declval< ValueType >))) {
  |
 ^~~~
struct basic_string

const struct basic_string *

# VUSE <.MEM_76>
return _13;
during GIMPLE pass: dom
signature4.cpp:58:163: internal compiler error: verify_gimple failed
0x2ef576c internal_error(char const*, ...)
/repo/gcc-trunk/gcc/diagnostic-global-context.cc:786
0x19782fd verify_gimple_in_cfg(function*, bool, bool)
/repo/gcc-trunk/gcc/tree-cfg.cc:5603
0x17d448a execute_function_todo
/repo/gcc-trunk/gcc/passes.cc:2097
0x17d495e execute_todo
/repo/gcc-trunk/gcc/passes.cc:2149
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.

I don't know if this is the same underlying issue.

[Bug c++/122185] [16 Regression] ICE: in propagate_necessity, at tree-ssa-dce.cc:1148 since r16-610-g3ecca8f3ad7e7f

2025-10-18 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122185

--- Comment #20 from Sam James  ---
Thanks, I can reproduce with that (even without profile data). I am not sure if
it's the same issue so I'll let pinskia rule on that.

[Bug c++/122185] [16 Regression] ICE: in propagate_necessity, at tree-ssa-dce.cc:1148 since r16-610-g3ecca8f3ad7e7f

2025-10-18 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122185

--- Comment #7 from Andrew Pinski  ---
(In reply to Sam James from comment #6)
> Right, started with r16-610-g3ecca8f3ad7e7f, but I guess latent then.

no that changed part of the folding here.

I think the reduced testcase is undefined.

Doing:
```
#include 
template  struct static_const {
  static constexpr T value{};
};
template  struct adl_serializer;
template  class = adl_serializer>
class basic_json;
struct from_json_fn {
  template 
  void operator()(BasicJsonType, T) const;
};
template  struct adl_serializer {
  template 
  static void from_json(BasicJsonType &&j, TargetType val) {
static_const::value(std::forward(j), val);
  }
};
struct iter_impl {
  basic_json<> operator*();
  void operator++();
  bool operator!=(iter_impl);
};
template  class JSONSerializer>
struct basic_json {
  template  using iter_impl = iter_impl;
  using iterator = iter_impl;
  template  void get_impl(int) {
auto ret = int();
JSONSerializer::from_json(*this, ret);
  }
  template  void get() { get_impl({}); }
  iterator begin();
  iterator end();
  char type_name;
};
void _ValidateSignatureFile() {
  basic_json signatures;
  for (auto signature : signatures)
signature.get();
}
```

Works still. That is get the correct definition of std::forward from utility.


Do you have the original preprocessed source where the ICE happens?

[Bug c++/122185] [16 Regression] ICE: in propagate_necessity, at tree-ssa-dce.cc:1148 since r16-610-g3ecca8f3ad7e7f

2025-10-18 Thread zsojka at seznam dot cz via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122185

--- Comment #24 from Zdenek Sojka  ---
I am unable to provide a valid testcase, as I can't write a check script that
would reject invalid testcase. This testcase compiles at -O0 without errors or
even warnings; normally invalid code is rejected at -O0 due to syntax error, or
the compiler ICEs, rejecting the testcase as well.
It might be well the case that a valid testcase triggering this ICE does not
exist.

[Bug c++/122185] [16 Regression] ICE: in propagate_necessity, at tree-ssa-dce.cc:1148 since r16-610-g3ecca8f3ad7e7f

2025-10-18 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122185

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P1

[Bug c++/122185] [16 Regression] ICE: in propagate_necessity, at tree-ssa-dce.cc:1148 since r16-610-g3ecca8f3ad7e7f

2025-10-18 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122185

--- Comment #8 from Andrew Pinski  ---
Looks like this code is originally from https://github.com/OpenTTD/OpenTTD .

[Bug c++/122185] [16 Regression] ICE: in propagate_necessity, at tree-ssa-dce.cc:1148 since r16-610-g3ecca8f3ad7e7f

2025-10-18 Thread zsojka at seznam dot cz via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122185

--- Comment #16 from Zdenek Sojka  ---
(In reply to Sam James from comment #14)
> Zdenek, I've tried our package in Gentoo as well as building manually on
> master (+ various option combinations) and I can't repro w/ OpenTTD yet.
> 
> Could you give me some hints for how you built OpenTTD, or email the
> preprocessed source to me and andrew?

Thank you for having a look; I am sorry for making it so complex by having that
undefined auto-reduced testcase. I didn't have time to clean it up.
I will have a look at this when I get back home in the evening.

[Bug c++/122185] [16 Regression] ICE: in propagate_necessity, at tree-ssa-dce.cc:1148 since r16-610-g3ecca8f3ad7e7f

2025-10-18 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122185

--- Comment #22 from Andrew Pinski  ---
```
0>>> COPY ret_2(D) = _13
Optimizing statement j ={v} {CLOBBER(eos)};
Optimizing statement return ret_2(D);
  Replaced 'ret_2(D)' with variable '_13'
```
Which dom does because of:
```
  if (ret_2(D) != _13)
goto ; [70.00%]
  else
goto ; [30.00%]
```

[Bug c++/122185] [16 Regression] ICE: in propagate_necessity, at tree-ssa-dce.cc:1148 since r16-610-g3ecca8f3ad7e7f

2025-10-18 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122185

Andrew Pinski  changed:

   What|Removed |Added

 CC||pinskia at gcc dot gnu.org

--- Comment #11 from Andrew Pinski  ---
To workaround broken/undefined definition of these std:: functions. Maybe
`if (INDIRECT_TYPE_P (TREE_TYPE (x)) == INDIRECT_TYPE_P (TREE_TYPE (r)))`
should be used instead of what was removed.

I am not sure that will fix all of the undefined code out there but at least
will fix this testcase.

[Bug c++/122185] [16 Regression] ICE: in propagate_necessity, at tree-ssa-dce.cc:1148 since r16-610-g3ecca8f3ad7e7f

2025-10-18 Thread zsojka at seznam dot cz via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122185

--- Comment #17 from Zdenek Sojka  ---
So far I am still reducing the testcase.
It is crashing at a different place, with different flags:

$ x86_64-pc-linux-gnu-gcc
'-DGLOBAL_DATA_DIR=\"/usr/local/share/games/openttd\"'
'-DPERSONAL_DIR=\".openttd\"' -DPOINTER_IS_64BIT -DTTD_ENDIAN=TTD_LITTLE_ENDIAN
-DUNIX -DWITH_ASSERT -DWITH_CURL -DWITH_FLUIDSYNTH -DWITH_FONTCONFIG
-DWITH_FREETYPE -DWITH_HARFBUZZ -DWITH_ICU_I18N -DWITH_LIBLZMA -DWITH_LZO
-DWITH_OPENGL -DWITH_PERSONAL_DIR -DWITH_PNG -DWITH_SDL2 -DWITH_SSE -DWITH_ZLIB
-I/repo/gcc-test/openttd3/src
-I/repo/gcc-test/openttd3/src/3rdparty/squirrel/include -I/usr/include/harfbuzz
-I/repo/gcc-test/openttd3/build/generated
-I/repo/gcc-test/openttd3/build/generated/script/api
-I/repo/gcc-test/openttd3/src/script/api
-I/repo/gcc-test/openttd3/build/generated/script
-I/repo/gcc-test/openttd3/build/generated/script/api/ai
-I/repo/gcc-test/openttd3/src/script/api/ai
-I/repo/gcc-test/openttd3/build/generated/script/api/game
-I/repo/gcc-test/openttd3/src/script/api/game
-I/repo/gcc-test/openttd3/build/generated/script/api/template
-I/repo/gcc-test/openttd3/src/script/api/template -isystem /usr/include/SDL2
-isystem /usr/include/freetype2 -fno-thread-jumps -O -fprofile-use -std=gnu++20
signature3.cpp -w
signature3.cpp: In member function 'ValueType
nlohmann::json_abi_v3_11_3::basic_json::get_impl(nlohmann::json_abi_v3_11_3::detail::priority_tag<0>)
const [with ValueType = std::__cxx11::basic_string; typename
std::enable_if<(nlohmann::json_abi_v3_11_3::detail::is_default_constructible::value
&&
nlohmann::json_abi_v3_11_3::detail::has_from_json,
ValueType>::value), int>::type  = 0; ObjectType = std::map;
ArrayType = std::vector; StringType = std::__cxx11::basic_string;
BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long
unsigned int; NumberFloatType = double; AllocatorType = std::allocator;
JSONSerializer = nlohmann::json_abi_v3_11_3::adl_serializer; BinaryType =
std::vector; CustomBaseClass = void]':
signature3.cpp:16509:15: error: invalid conversion in return statement
16509 | JSONSerializer::from_json(std::declval(), std::declval(
  |   ^ ~~
struct basic_string

const struct string_t *

# VUSE <.MEM_7>
return _16;
during GIMPLE pass: dom
signature3.cpp:16509:15: internal compiler error: verify_gimple failed
0x2ef53ac internal_error(char const*, ...)
/repo/gcc-trunk/gcc/diagnostic-global-context.cc:786
0x19781bd verify_gimple_in_cfg(function*, bool, bool)
/repo/gcc-trunk/gcc/tree-cfg.cc:5603
0x17d434a execute_function_todo
/repo/gcc-trunk/gcc/passes.cc:2097
0x17d481e execute_todo
/repo/gcc-trunk/gcc/passes.cc:2149
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.

[Bug c++/122185] [16 Regression] ICE: in propagate_necessity, at tree-ssa-dce.cc:1148 since r16-610-g3ecca8f3ad7e7f

2025-10-18 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122185

--- Comment #15 from Sam James  ---
Created attachment 62516
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62516&action=edit
signature.cpp.ii.xz (working)

I've attached my signature.cpp.ii.xz from one attempt:

g++ -DGLOBAL_DATA_DIR=\"/usr/share/openttd\" -DNDEBUG
-DPERSONAL_DIR=\".openttd\" -DPOINTER_IS_64BIT -DTTD_ENDIAN=TTD_LITTLE_ENDIAN
-DUNIX -DWITH_CURL -DWITH_FLUIDSYNTH -DWITH_FONTCONFIG -DWITH_FREETYPE
-DWITH_HARFBUZZ -DWITH_ICU_I18N -DWITH_ICU_UC -DWITH_LIBLZMA -DWITH_OPENGL
-DWITH_PERSONAL_DIR -DWITH_PNG -DWITH_SDL2 -DWITH_SSE -DWITH_ZLIB
-I/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1/src
-I/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1/src/3rdparty/squirrel/include
-I/usr/include/harfbuzz
-I/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1_build/generated
-I/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1_build/generated/script/api
-I/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1/src/script/api
-I/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1_build/generated/script
-I/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1_build/generated/script/api/ai
-I/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1/src/script/api/ai
-I/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1_build/generated/script/api/game
-I/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1/src/script/api/game
-I/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1_build/generated/script/api/template
-I/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1/src/script/api/template
-isystem /usr/include/SDL2 -isystem /usr/include/freetype2 -std=c++20
-fdiagnostics-color=always -finput-charset=utf-8  -MD -MT
CMakeFiles/openttd_lib.dir/src/signature.cpp.o -MF
CMakeFiles/openttd_lib.dir/src/signature.cpp.o.d -o
CMakeFiles/openttd_lib.dir/src/signature.cpp.o -c
/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1/src/signature.cpp
-save-temps -O

in case it's useful for comparison, but I'm a loss for now.

[Bug c++/122185] [16 Regression] ICE: in propagate_necessity, at tree-ssa-dce.cc:1148 since r16-610-g3ecca8f3ad7e7f

2025-10-17 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122185

--- Comment #23 from Sam James  ---
OK, let's use newly-created PR15 for that second issue (the dom one ).

This bug is for the C++ weirdness, for which we still need a valid testcase.

[Bug c++/122185] [16 Regression] ICE: in propagate_necessity, at tree-ssa-dce.cc:1148 since r16-610-g3ecca8f3ad7e7f

2025-10-17 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122185

--- Comment #9 from Andrew Pinski  ---
(In reply to Andrew Pinski from comment #8)
> Looks like this code is originally from https://github.com/OpenTTD/OpenTTD .

Specifically:
https://github.com/OpenTTD/OpenTTD/blob/a617d009cca418255a9682fd83c9cebc6423303e/src/signature.cpp#L194

[Bug c++/122185] [16 Regression] ICE: in propagate_necessity, at tree-ssa-dce.cc:1148 since r16-610-g3ecca8f3ad7e7f

2025-10-17 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122185

--- Comment #21 from Andrew Pinski  ---
(In reply to Zdenek Sojka from comment #19)
> Created attachment 62523 [details]
> reduced (?) signature.cpp, including system headers, crashing at a different
> place
> 
> This is probably the best I can provide:

That one fails even in GCC 15.  So it is definitely 2 differnet issues here.

[Bug c++/122185] [16 Regression] ICE: in propagate_necessity, at tree-ssa-dce.cc:1148 since r16-610-g3ecca8f3ad7e7f

2025-10-08 Thread zsojka at seznam dot cz via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122185

--- Comment #18 from Zdenek Sojka  ---
(In reply to Sam James from comment #15)
> Created attachment 62516 [details]
> signature.cpp.ii.xz (working)
> 
> I've attached my signature.cpp.ii.xz from one attempt:
> 
> g++ -DGLOBAL_DATA_DIR=\"/usr/share/openttd\" -DNDEBUG
> -DPERSONAL_DIR=\".openttd\" -DPOINTER_IS_64BIT
> -DTTD_ENDIAN=TTD_LITTLE_ENDIAN -DUNIX -DWITH_CURL -DWITH_FLUIDSYNTH
> -DWITH_FONTCONFIG -DWITH_FREETYPE -DWITH_HARFBUZZ -DWITH_ICU_I18N
> -DWITH_ICU_UC -DWITH_LIBLZMA -DWITH_OPENGL -DWITH_PERSONAL_DIR -DWITH_PNG
> -DWITH_SDL2 -DWITH_SSE -DWITH_ZLIB
> -I/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1/src
> -I/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1/src/
> 3rdparty/squirrel/include -I/usr/include/harfbuzz
> -I/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1_build/
> generated
> -I/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1_build/
> generated/script/api
> -I/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1/src/
> script/api
> -I/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1_build/
> generated/script
> -I/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1_build/
> generated/script/api/ai
> -I/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1/src/
> script/api/ai
> -I/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1_build/
> generated/script/api/game
> -I/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1/src/
> script/api/game
> -I/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1_build/
> generated/script/api/template
> -I/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1/src/
> script/api/template -isystem /usr/include/SDL2 -isystem
> /usr/include/freetype2 -std=c++20 -fdiagnostics-color=always
> -finput-charset=utf-8  -MD -MT
> CMakeFiles/openttd_lib.dir/src/signature.cpp.o -MF
> CMakeFiles/openttd_lib.dir/src/signature.cpp.o.d -o
> CMakeFiles/openttd_lib.dir/src/signature.cpp.o -c
> /var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1/src/
> signature.cpp -save-temps -O
> 
> in case it's useful for comparison, but I'm a loss for now.

It fails with different flags, at a different place:

$ x86_64-pc-linux-gnu-gcc -fno-thread-jumps -O -fprofile-use -std=gnu++20
signature.cpp.ii -w
In file included from
/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1/src/signature.cpp:20:
/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1/src/3rdparty/nlohmann/json.hpp:
In member function 'ValueType
nlohmann::json_abi_v3_12_0::basic_json::get_impl(nlohmann::json_abi_v3_12_0::detail::priority_tag<0>)
const [with ValueType = std::__cxx11::basic_string; typename
std::enable_if<(nlohmann::json_abi_v3_12_0::detail::is_default_constructible::value
&&
nlohmann::json_abi_v3_12_0::detail::has_from_json,
ValueType>::value), int>::type  = 0; ObjectType = std::map;
ArrayType = std::vector; StringType = std::__cxx11::basic_string;
BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long
unsigned int; NumberFloatType = double; AllocatorType = std::allocator;
JSONSerializer = nlohmann::json_abi_v3_12_0::adl_serializer; BinaryType =
std::vector; CustomBaseClass = void]':
/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1/src/3rdparty/nlohmann/json.hpp:1633:15:
error: invalid conversion in return statement
struct basic_string

const struct string_t *

# VUSE <.MEM_7>
return _16;
during GIMPLE pass: dom
/var/tmp/portage/games-simulation/openttd-14.1/work/openttd-14.1/src/3rdparty/nlohmann/json.hpp:1633:15:
internal compiler error: verify_gimple failed
0x2ef576c internal_error(char const*, ...)
/repo/gcc-trunk/gcc/diagnostic-global-context.cc:786
0x19782fd verify_gimple_in_cfg(function*, bool, bool)
/repo/gcc-trunk/gcc/tree-cfg.cc:5603
0x17d448a execute_function_todo
/repo/gcc-trunk/gcc/passes.cc:2097
0x17d495e execute_todo
/repo/gcc-trunk/gcc/passes.cc:2149
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.

[Bug c++/122185] [16 Regression] ICE: in propagate_necessity, at tree-ssa-dce.cc:1148 since r16-610-g3ecca8f3ad7e7f

2025-10-08 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122185

--- Comment #14 from Sam James  ---
Zdenek, I've tried our package in Gentoo as well as building manually on master
(+ various option combinations) and I can't repro w/ OpenTTD yet.

Could you give me some hints for how you built OpenTTD, or email the
preprocessed source to me and andrew?

[Bug c++/122185] [16 Regression] ICE: in propagate_necessity, at tree-ssa-dce.cc:1148 since r16-610-g3ecca8f3ad7e7f

2025-10-07 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122185

Sam James  changed:

   What|Removed |Added

 CC||ville.voutilainen at gmail dot 
com
Summary|[16 Regression] ICE: in |[16 Regression] ICE: in
   |propagate_necessity, at |propagate_necessity, at
   |tree-ssa-dce.cc:1148|tree-ssa-dce.cc:1148 since
   ||r16-610-g3ecca8f3ad7e7f
   Keywords|needs-bisection |

--- Comment #6 from Sam James  ---
Right, started with r16-610-g3ecca8f3ad7e7f, but I guess latent then.

[Bug c++/122185] [16 Regression] ICE: in propagate_necessity, at tree-ssa-dce.cc:1148 since r16-610-g3ecca8f3ad7e7f

2025-10-07 Thread zsojka at seznam dot cz via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122185

--- Comment #10 from Zdenek Sojka  ---
(In reply to Andrew Pinski from comment #9)
> (In reply to Andrew Pinski from comment #8)
> > Looks like this code is originally from https://github.com/OpenTTD/OpenTTD .
> 
> Specifically:
> https://github.com/OpenTTD/OpenTTD/blob/
> a617d009cca418255a9682fd83c9cebc6423303e/src/signature.cpp#L194

You are very right about that.

I don't know what are the flags needed to compile that file in order to get
this error.
I avoid providing the full pre-processed source, as I don't know if that
wouldn't violate the license.

[Bug c++/122185] [16 Regression] ICE: in propagate_necessity, at tree-ssa-dce.cc:1148 since r16-610-g3ecca8f3ad7e7f

2025-10-06 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122185

--- Comment #13 from Andrew Pinski  ---
(In reply to Zdenek Sojka from comment #10)
> (In reply to Andrew Pinski from comment #9)
> > (In reply to Andrew Pinski from comment #8)
> > > Looks like this code is originally from 
> > > https://github.com/OpenTTD/OpenTTD .
> > 
> > Specifically:
> > https://github.com/OpenTTD/OpenTTD/blob/
> > a617d009cca418255a9682fd83c9cebc6423303e/src/signature.cpp#L194
> 
> You are very right about that.
> 
> I don't know what are the flags needed to compile that file in order to get
> this error.
> I avoid providing the full pre-processed source, as I don't know if that
> wouldn't violate the license.

In this case OpenTTD is GPL code so it should be ok.  The reason why I am
asking is because the reduced auto-reduced testcase made it into undefined due
to the definition of std::forward that it created. namespace std is special and
functions even without being "builtins" are folded and that folding is what is
going wrong in this reduced testcase but I am not 100% sure what is happening
in the original case.

[Bug c++/122185] [16 Regression] ICE: in propagate_necessity, at tree-ssa-dce.cc:1148 since r16-610-g3ecca8f3ad7e7f

2025-10-06 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122185

Sam James  changed:

   What|Removed |Added

 CC||sjames at gcc dot gnu.org

--- Comment #12 from Sam James  ---
(In reply to Zdenek Sojka from comment #10)

Let me look.