[llvm-bugs] [Bug 41243] New: C++17 frontend segmentation

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Mar 26 10:44:58 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=41243

            Bug ID: 41243
           Summary: C++17 frontend segmentation
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++'17
          Assignee: unassignedclangbugs at nondot.org
          Reporter: d.j.bogan at outlook.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

clang: error: unable to execute command: Segmentation fault: 11
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin18.2.0
Thread model: posix

Something todo with the "linkage" (static char const[]) in template function. 

gcc trunk
In instantiation of 'constexpr std::make_integer_sequence<int, 3> keyCheck<5,
(& test1)>::idxs':
<source>:97:1:   required from here
<source>:20:58: internal compiler error: in discriminator_for_local_entity, at
cp/mangle.c:1901
   20 |     static constexpr std::make_integer_sequence<int,N-2> idxs{};
      |                                                          ^~~~
###
/*
 * test.cpp
 */
###
#include <cassert>

#include <functional>
#include <iostream>
#include <sstream>
#include <string>
#include <type_traits>
#include <utility>

using namespace std::literals::string_literals;

template<int N,char const * key> 
struct keyCheck {


    static constexpr std::make_integer_sequence<int,N-2> idxs{};

    template<typename T,template<typename,T...> class ls_t,T ...Idxs>
    static bool check_helper(std::istream& is,ls_t<T,Idxs...> idxs){
        char s;
        return (  ... && ( is.get(s) && (s == key[Idxs]) ) );
    }

    static bool check(std::istream& is){
        return keyCheck::check_helper(is,idxs);
    }
};

static char const stest1[]{"test1"};  
extern char const etest1[]{"test1"};

#define stringer(X) sizeof(X),X

template<typename T>
void test4(T z){

    std::string s1{"test1"s};
    std::stringstream ss1{s1};

    assert(keyCheck<stringer(stest1)>::check(ss1));

}


template<typename T>
void test3(T z){

    std::string s1{"test1"s};
    std::stringstream ss1{s1};

    assert(keyCheck<stringer(etest1)>::check(ss1));

}


void test2(int z){

    static char const test1[]{"test"};
    std::string s1{"test1"s};
    std::stringstream ss1{s1};

    assert(keyCheck<stringer(test1)>::check(ss1));

}

template<int=0>
void test5(){

    static char const test1[]{"test"};
    std::string s1{"test1"s};
    std::stringstream ss1{s1};

    assert(keyCheck<stringer(test1)>::check(ss1));

}

template<typename T>
void test(T z){

    static char const test1[]{"test"};
    std::string s1{"test1"s};
    std::stringstream ss1{s1};

    assert(keyCheck<stringer(test1)>::check(ss1));

}

int main(){
    test(1);
    test2(2);
    test3(3);
    test4(4);
    test5();
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190326/974f473d/attachment-0001.html>


More information about the llvm-bugs mailing list