1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // UNSUPPORTED: c++03, c++11, c++14, c++17 10 11 // Ensure that strings which fit within the SSO size can be constant-initialized 12 // as both a global and local. 13 14 #include <string> 15 16 #if __SIZE_WIDTH__ == 64 17 # define LONGEST_STR "0123456789012345678901" 18 #elif __SIZE_WIDTH__ == 32 19 # define LONGEST_STR "0123456789" 20 #else 21 # error "std::size_t has an unexpected size" 22 #endif 23 24 constinit std::string g_str = LONGEST_STR; fn()25void fn() { constexpr std::string l_str = LONGEST_STR; } 26