Warnings compiling `test/vis_stress.cpp` with g++ 14 and `-Wextra`
Issue #623
new
When using the newly released GCC 14.1 compilers, builds of the vis_stress
test generate numerous -Walloc-size
warnings for some len=0
template instantiations in testing with -Wextra
.
This is new since GCC 13.2.
This is independent of CPU (seen wth both x86_64
and aarch64
), code mode, thread mode and network.
==============================================================================
$ /[redacted]/upcxx-inst/bin/upcxx -o vis_stress-seq /[redacted]/upcxx/test/vis_stress.cpp
/[redacted]/upcxx/test/vis_stress.cpp: In instantiation of 'void ops_as_regular::put(const T*, upcxx::global_ptr<T>) [with T = unsigned char; int len = 0]':
/[redacted]/upcxx/test/vis_stress.cpp:116:29: required from 'void test_case(Ops) [with Uint = unsigned char; int len = 0; Ops = ops_as_regular]'
116 | ops.template put<Uint,len>((Uint const*)src_data, nebr_ptr);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/[redacted]/upcxx/test/vis_stress.cpp:141:22: required from 'void sweep_given_len() [with Uint = unsigned char; int len = 0]'
141 | test_case<Uint,len>(ops_as_regular());
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/[redacted]/upcxx/test/vis_stress.cpp:148:26: required from 'void sweep_given_type() [with Uint = unsigned char]'
148 | sweep_given_len<Uint,0>();
| ~~~~~~~~~~~~~~~~~~~~~~~^~
/[redacted]/upcxx/test/vis_stress.cpp:163:28: required from here
163 | sweep_given_type<uint8_t>();
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~
/[redacted]/upcxx/test/vis_stress.cpp:13:21: warning: allocation of insufficient size '0' for type 'const unsigned char*' with size '8' [-Walloc-size]
13 | auto src_ptrs = new T const*[len];
| ^~~~~~~~~~~~~~~~~
/[redacted]/upcxx/test/vis_stress.cpp: In instantiation of 'void ops_as_regular::get(upcxx::global_ptr<T>, T*) [with T = unsigned char; int len = 0]':
/[redacted]/upcxx/test/vis_stress.cpp:126:31: required from 'void test_case(Ops) [with Uint = unsigned char; int len = 0; Ops = ops_as_regular]'
126 | ops.template get<Uint,len>(nebr_ptr, got_data);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/[redacted]/upcxx/test/vis_stress.cpp:141:22: required from 'void sweep_given_len() [with Uint = unsigned char; int len = 0]'
141 | test_case<Uint,len>(ops_as_regular());
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/[redacted]/upcxx/test/vis_stress.cpp:148:26: required from 'void sweep_given_type() [with Uint = unsigned char]'
148 | sweep_given_len<Uint,0>();
| ~~~~~~~~~~~~~~~~~~~~~~~^~
/[redacted]/upcxx/test/vis_stress.cpp:163:28: required from here
163 | sweep_given_type<uint8_t>();
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~
/[redacted]/upcxx/test/vis_stress.cpp:30:22: warning: allocation of insufficient size '0' for type 'unsigned char*' with size '8' [-Walloc-size]
30 | auto dest_ptrs = new T*[len];
| ^~~~~~~~~~~
/[redacted]/upcxx/test/vis_stress.cpp: In instantiation of 'void ops_as_regular::put(const T*, upcxx::global_ptr<T>) [with T = short unsigned int; int len = 0]':
/[redacted]/upcxx/test/vis_stress.cpp:116:29: required from 'void test_case(Ops) [with Uint = short unsigned int; int len = 0; Ops = ops_as_regular]'
116 | ops.template put<Uint,len>((Uint const*)src_data, nebr_ptr);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/[redacted]/upcxx/test/vis_stress.cpp:141:22: required from 'void sweep_given_len() [with Uint = short unsigned int; int len = 0]'
141 | test_case<Uint,len>(ops_as_regular());
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/[redacted]/upcxx/test/vis_stress.cpp:148:26: required from 'void sweep_given_type() [with Uint = short unsigned int]'
148 | sweep_given_len<Uint,0>();
| ~~~~~~~~~~~~~~~~~~~~~~~^~
/[redacted]/upcxx/test/vis_stress.cpp:164:29: required from here
164 | sweep_given_type<uint16_t>();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/[redacted]/upcxx/test/vis_stress.cpp:13:21: warning: allocation of insufficient size '0' for type 'const short unsigned int*' with size '8' [-Walloc-size]
13 | auto src_ptrs = new T const*[len];
| ^~~~~~~~~~~~~~~~~
/[redacted]/upcxx/test/vis_stress.cpp: In instantiation of 'void ops_as_regular::get(upcxx::global_ptr<T>, T*) [with T = short unsigned int; int len = 0]':
/[redacted]/upcxx/test/vis_stress.cpp:126:31: required from 'void test_case(Ops) [with Uint = short unsigned int; int len = 0; Ops = ops_as_regular]'
126 | ops.template get<Uint,len>(nebr_ptr, got_data);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/[redacted]/upcxx/test/vis_stress.cpp:141:22: required from 'void sweep_given_len() [with Uint = short unsigned int; int len = 0]'
141 | test_case<Uint,len>(ops_as_regular());
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/[redacted]/upcxx/test/vis_stress.cpp:148:26: required from 'void sweep_given_type() [with Uint = short unsigned int]'
148 | sweep_given_len<Uint,0>();
| ~~~~~~~~~~~~~~~~~~~~~~~^~
/[redacted]/upcxx/test/vis_stress.cpp:164:29: required from here
164 | sweep_given_type<uint16_t>();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/[redacted]/upcxx/test/vis_stress.cpp:30:22: warning: allocation of insufficient size '0' for type 'short unsigned int*' with size '8' [-Walloc-size]
30 | auto dest_ptrs = new T*[len];
| ^~~~~~~~~~~
/[redacted]/upcxx/test/vis_stress.cpp: In instantiation of 'void ops_as_regular::put(const T*, upcxx::global_ptr<T>) [with T = unsigned int; int len = 0]':
/[redacted]/upcxx/test/vis_stress.cpp:116:29: required from 'void test_case(Ops) [with Uint = unsigned int; int len = 0; Ops = ops_as_regular]'
116 | ops.template put<Uint,len>((Uint const*)src_data, nebr_ptr);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/[redacted]/upcxx/test/vis_stress.cpp:141:22: required from 'void sweep_given_len() [with Uint = unsigned int; int len = 0]'
141 | test_case<Uint,len>(ops_as_regular());
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/[redacted]/upcxx/test/vis_stress.cpp:148:26: required from 'void sweep_given_type() [with Uint = unsigned int]'
148 | sweep_given_len<Uint,0>();
| ~~~~~~~~~~~~~~~~~~~~~~~^~
/[redacted]/upcxx/test/vis_stress.cpp:165:29: required from here
165 | sweep_given_type<uint32_t>();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/[redacted]/upcxx/test/vis_stress.cpp:13:21: warning: allocation of insufficient size '0' for type 'const unsigned int*' with size '8' [-Walloc-size]
13 | auto src_ptrs = new T const*[len];
| ^~~~~~~~~~~~~~~~~
/[redacted]/upcxx/test/vis_stress.cpp: In instantiation of 'void ops_as_regular::get(upcxx::global_ptr<T>, T*) [with T = unsigned int; int len = 0]':
/[redacted]/upcxx/test/vis_stress.cpp:126:31: required from 'void test_case(Ops) [with Uint = unsigned int; int len = 0; Ops = ops_as_regular]'
126 | ops.template get<Uint,len>(nebr_ptr, got_data);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/[redacted]/upcxx/test/vis_stress.cpp:141:22: required from 'void sweep_given_len() [with Uint = unsigned int; int len = 0]'
141 | test_case<Uint,len>(ops_as_regular());
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/[redacted]/upcxx/test/vis_stress.cpp:148:26: required from 'void sweep_given_type() [with Uint = unsigned int]'
148 | sweep_given_len<Uint,0>();
| ~~~~~~~~~~~~~~~~~~~~~~~^~
/[redacted]/upcxx/test/vis_stress.cpp:165:29: required from here
165 | sweep_given_type<uint32_t>();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/[redacted]/upcxx/test/vis_stress.cpp:30:22: warning: allocation of insufficient size '0' for type 'unsigned int*' with size '8' [-Walloc-size]
30 | auto dest_ptrs = new T*[len];
| ^~~~~~~~~~~
/[redacted]/upcxx/test/vis_stress.cpp: In instantiation of 'void ops_as_regular::put(const T*, upcxx::global_ptr<T>) [with T = long unsigned int; int len = 0]':
/[redacted]/upcxx/test/vis_stress.cpp:116:29: required from 'void test_case(Ops) [with Uint = long unsigned int; int len = 0; Ops = ops_as_regular]'
116 | ops.template put<Uint,len>((Uint const*)src_data, nebr_ptr);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/[redacted]/upcxx/test/vis_stress.cpp:141:22: required from 'void sweep_given_len() [with Uint = long unsigned int; int len = 0]'
141 | test_case<Uint,len>(ops_as_regular());
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/[redacted]/upcxx/test/vis_stress.cpp:148:26: required from 'void sweep_given_type() [with Uint = long unsigned int]'
148 | sweep_given_len<Uint,0>();
| ~~~~~~~~~~~~~~~~~~~~~~~^~
/[redacted]/upcxx/test/vis_stress.cpp:166:29: required from here
166 | sweep_given_type<uint64_t>();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/[redacted]/upcxx/test/vis_stress.cpp:13:21: warning: allocation of insufficient size '0' for type 'const long unsigned int*' with size '8' [-Walloc-size]
13 | auto src_ptrs = new T const*[len];
| ^~~~~~~~~~~~~~~~~
/[redacted]/upcxx/test/vis_stress.cpp: In instantiation of 'void ops_as_regular::get(upcxx::global_ptr<T>, T*) [with T = long unsigned int; int len = 0]':
/[redacted]/upcxx/test/vis_stress.cpp:126:31: required from 'void test_case(Ops) [with Uint = long unsigned int; int len = 0; Ops = ops_as_regular]'
126 | ops.template get<Uint,len>(nebr_ptr, got_data);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/[redacted]/upcxx/test/vis_stress.cpp:141:22: required from 'void sweep_given_len() [with Uint = long unsigned int; int len = 0]'
141 | test_case<Uint,len>(ops_as_regular());
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/[redacted]/upcxx/test/vis_stress.cpp:148:26: required from 'void sweep_given_type() [with Uint = long unsigned int]'
148 | sweep_given_len<Uint,0>();
| ~~~~~~~~~~~~~~~~~~~~~~~^~
/[redacted]/upcxx/test/vis_stress.cpp:166:29: required from here
166 | sweep_given_type<uint64_t>();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/[redacted]/upcxx/test/vis_stress.cpp:30:22: warning: allocation of insufficient size '0' for type 'long unsigned int*' with size '8' [-Walloc-size]
30 | auto dest_ptrs = new T*[len];
| ^~~~~~~~~~~
==============================================================================
Comments (2)
-
reporter -
reporter - edited description
- Log in to comment
The 2-line patch below is sufficient to eliminate the warning, with the test still passing. However, since I do not know if this change is dependent on undefined behavior I include it here rather "for reference" rather than proposing to commit it.