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

            Bug ID: 120105
           Summary: -Wpadded leads to internal_error
           Product: gcc
           Version: 15.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: joo.peter at gmail dot com
  Target Milestone: ---

The minimal example is this main.cpp:


    #include <map>

    struct foo
    {
        alignas(8) int bar;
    };

    int main()
    {
        std::map<int, foo>{}.emplace(1, foo{});
    }


The compilation command which triggers the problem:


    g++ -c main.cpp -o /dev/null -Wpadded -Wsystem-headers


The internal_error of gcc's output is this:


   
/opt/compiler-explorer/gcc-15.1.0/include/c++/15.1.0/bits/stl_pair.h:302:12:
warning: padding struct size to alignment boundary with 7 bytes [-Wpadded]
      302 |     struct pair
          |            ^~~~
    /opt/compiler-explorer/gcc-15.1.0/include/c++/15.1.0/bits/stl_pair.h: In
instantiation of 'struct std::pair<const int, foo>':
    /opt/compiler-explorer/gcc-15.1.0/include/c++/15.1.0/bits/stl_map.h:622:15:
  in strip_typedefs, at cp/tree.cc:1887
    0x2287465 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
        ???:0
    0x22989b6 internal_error(char const*, ...)
        ???:0
    0x7d443e fancy_abort(char const*, int, char const*)
        ???:0
    0x98bb45 canonicalize_type_argument(tree_node*, int)
        ???:0
    0x99a67c coerce_template_parms(tree_node*, tree_node*, tree_node*, int,
bool)
        ???:0
    0x9bb119 lookup_template_class(tree_node*, tree_node*, tree_node*,
tree_node*, int)
        ???:0
    0x9ab456 tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
    0x9abc1c tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
    0x9abc1c tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
    0x9b2467 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
        ???:0
    0x9ab435 tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
    0x9abc1c tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
    0x22a4c53 pretty_printer::format(text_info&)
        ???:0
    0x22a6ed3 pp_verbatim(pretty_printer*, char const*, ...)
        ???:0
    0x2296158
diagnostic_text_output_format::on_report_diagnostic(diagnostic_info const&,
diagnostic_t)
        ???:0
    0x2287092 diagnostic_context::report_diagnostic(diagnostic_info*)
        ???:0
    0x2287465 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
        ???:0
    0x2297211 warning(diagnostic_option_id, char const*, ...)
        ???:0
    0xfd3a80 place_field(record_layout_info_s*, tree_node*)
        ???:0
    0x818147 finish_struct_1(tree_node*)
        ???:0
    Please submit a full bug report, with preprocessed source (by using
-freport-bug).
    Please include the complete backtrace with any bug report.
    See <https://gcc.gnu.org/bugs/> for instructions.


Without the '-Wpadded -Wsystem-headers' part gcc compiles this main.cpp just
fine.

I reproduced this problem on my arch linux using gcc 14.2.1, but also, I
reproduced it on godbolt too, using gcc 15.1.0
    https://godbolt.org/z/dr79EbxhM

Reply via email to