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

            Bug ID: 118296
           Summary: internal compiler error: in cxx_eval_bare_aggregate,
                    at cp/constexpr.cc  WHEN block{...}appeared in [...]
           Product: gcc
           Version: 14.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: terryinzaghi at 163 dot com
  Target Milestone: ---

internal compiler error: in cxx_eval_bare_aggregate, at cp/constexpr.cc:5301

WHEN  put 
     {...}/*to match std::initializer_list*/  
     into 
     [...]/*multi params array subscriptoperator*/  


gcc  14.2 

/*Code Can Trigger This Error*/



#include <cstdint>
#include <type_traits>
#include <initializer_list>

struct J {
  const char* _key = nullptr;
  constexpr J(std::initializer_list<J> l)                                      
                   {}
  constexpr J(double)                                                          
                   {}
  template<typename T> requires(std::is_integral_v<T>)constexpr J(T v)         
                   {}
  constexpr J(bool)                                                            
                   {}
  template<std::size_t N>constexpr J(const char(&s)[N])                        
                   {}
  constexpr J(std::nullptr_t)                                                  
                   {} 
};

struct Array  {
    constexpr J operator[](auto... Js) const {
           return(J{Js...});
        };      
};
static constexpr auto a = Array{};


struct Key {
    const char* _key = nullptr;
    constexpr Key(){}
    template<std::size_t N>constexpr auto operator[](const char(&s)[N]) const{
        Key nk{};
        nk._key =s;
        return(nk);
    };
    constexpr J operator=(J j)              const{
        j._key = _key;
        return(j);
    };

};
static constexpr auto k = Key{};


int main() { 

    constexpr J json = {
        k["abc"] = 1.1,
        k["def"] = true,
        k["ghi"] = false,
        k["kk"]  = nullptr,
        k["str"] = "sssssssssssssssssssssssssssssss",
        k["dict"]  = {
           k["aaa"] = 1.1,
           k["def"] = true,
           k["ghi"] = false,
           k["kk"]  = nullptr            
        },
        k["ary"] = a[
            1.1,
            true,
            false,
            nullptr,
            ////<remove this block will make it work>
            {
                   k["abc"] = 1.1,
                   k["def"] = true,
                   k["ghi"] = false,
                   k["kk"]  = nullptr,
                   k["dict"]  = {
                       k["abc"] = 1.1,
                       k["def"] = true,
                       k["ghi"] = false,
                       k["kk"]  = nullptr            
                  }              
            },
            ////</remove this block will make it work>
            1.1,
            true,
            false,
            nullptr,
            a[1,2,3,4,5]
        ]
     };  
};

Reply via email to