Debian Codegraph @

gcc/testsuite/g++.dg/warn/Wsizeof-array-div3.C

raw
1 // PR c++/114983
2 // { dg-do compile { target c++11 } }
3 // { dg-options "-Wsizeof-array-div" }
4
5 using size_t = decltype (sizeof (0));
6 unsigned int samplesBuffer[40];
7
8 template <typename T>
9 constexpr inline size_t fn1()
10 {
11 return ((sizeof(samplesBuffer)) / (sizeof(T))); // { dg-bogus "expression does not compute" }
12 }
13
14 template <typename T>
15 constexpr inline size_t fn2()
16 {
17 return ((sizeof(samplesBuffer)) / sizeof(T)); // { dg-warning "expression does not compute" }
18 }
19
20 size_t
21 g ()
22 {
23 auto sz = sizeof (samplesBuffer) / (sizeof(unsigned char));
24 sz += fn1<unsigned char>();
25 sz += fn2<unsigned char>(); // { dg-message "required from here" }
26 return sz;
27 }