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

            Bug ID: 113263
           Summary: ICE for invalid code for compound literal and type
                    definition in return type
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: muecker at gwdg dot de
  Target Milestone: ---

The following example ICEs after invalid code (it is valid C but not C++)

https://godbolt.org/z/7zrbxPraM
(partially minimized from: C example https://godbolt.org/z/M7n7o1r8h)

#define TOKEN_CONCAT_EX(x, y) x##y
#define TOKEN_CONCAT(x, y)    TOKEN_CONCAT_EX(x, y)
#define UNIQUIFY(x)           TOKEN_CONCAT(x, __LINE__)

#define ResultBody(T, E) { bool _is_ok; union { T _ok; E _err; }; }
#define ResultName(T, E) result_##T##_##E
#define ResultEx(T, E, T_N, E_N) struct ResultName(T_N, E_N) ResultBody(T, E)
#define Result(T, E) ResultEx(T, E, T, E)

#define Err(R, V) ((R) { ._is_ok = false, ._err = V, })


typedef struct
{
  int val;
} thing_t;

Result(thing_t, bool) maybe_make_thing(int v)
{
   return Err(Result(thing_t, bool), v == 200);
}

Reply via email to