diff options
-rw-r--r-- | gcc/testsuite/g++.dg/isan/constexpr.C | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/isan/constexpr.C b/gcc/testsuite/g++.dg/isan/constexpr.C index 4896396397b..b47511e3621 100644 --- a/gcc/testsuite/g++.dg/isan/constexpr.C +++ b/gcc/testsuite/g++.dg/isan/constexpr.C @@ -6,3 +6,25 @@ constexpr int foo (int i) { return std::__lg (i); } + +constexpr const char *string = "hello"; + +constexpr unsigned int str2int(const char *str, int h = 0) { + return !str[h] ? 5381 : (str2int(str, h + 1) * 33) ^ str[h]; +} + + +constexpr unsigned int arr[] = {1, 2, 3, 4, 5}; + +constexpr unsigned int index = 1; + +class A +{ + static constexpr const unsigned int *ptr = arr + index; +}; + +int main () +{ + constexpr unsigned int result_value = str2int (string); + A a; +} |