Bug 91493 - g++ 9.2.1 crashes compiling clickhouse
Summary: g++ 9.2.1 crashes compiling clickhouse
Status: WAITING
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 9.2.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-08-20 01:40 UTC by Rafael David Tinoco
Modified: 2019-08-21 13:33 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2019-08-20 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rafael David Tinoco 2019-08-20 01:40:04 UTC
The following function:

std::string toString(const ColumnDefaultKind kind)
{
    static const std::unordered_map<ColumnDefaultKind, std::string> map{
        { ColumnDefaultKind::Default, AliasNames::DEFAULT },
        { ColumnDefaultKind::Materialized, AliasNames::MATERIALIZED },
        { ColumnDefaultKind::Alias, AliasNames::ALIAS }
    };

    const auto it = map.find(kind);
    return it != std::end(map) ? it->second : throw Exception{"Invalid ColumnDefaultKind", ErrorCodes::LOGICAL_ERROR};
}

causes gcc9 (with attached dump) to crash while other similar function (in related syntax):

ColumnDefaultKind columnDefaultKindFromString(const std::string & str)
{
    static const std::unordered_map<std::string, ColumnDefaultKind> map{
        { AliasNames::DEFAULT, ColumnDefaultKind::Default },
        { AliasNames::MATERIALIZED, ColumnDefaultKind::Materialized },
        { AliasNames::ALIAS, ColumnDefaultKind::Alias }
    };

    const auto it = map.find(str);
    return it != std::end(map) ? it->second : throw Exception{"Unknown column default specifier: " + str, ErrorCodes::LOGICAL_ERROR};
}

does not. Changing the syntax to:

std::string toString(const ColumnDefaultKind kind)
{
    static const std::unordered_map<ColumnDefaultKind, std::string> map{
        { ColumnDefaultKind::Default, AliasNames::DEFAULT },
        { ColumnDefaultKind::Materialized, AliasNames::MATERIALIZED },
        { ColumnDefaultKind::Alias, AliasNames::ALIAS }
    };

    const auto it = map.find(kind);

    if (it != std::end(map))
        throw Exception{"Invalid ColumnDefaultKind", ErrorCodes::LOGICAL_ERROR};

    return it->second;
}

fixes the issue.
Comment 1 Richard Biener 2019-08-20 07:32:24 UTC
Please provide a testcase that can be compiled.
Comment 2 Rafael David Tinoco 2019-08-20 15:08:36 UTC
Related:

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

Possibly a duplicate.