-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Currently, Verstable specifically supports the following compiler diagnostics settings: -Wall -Wextra -pedantic in GCC and Clang and /W4 in MSVC. However, it could be beneficial, from the standpoint of user experience and stricter quality control, to support some commonly used additional warnings. For example, @rsmarples has indicated that in addition to the above GCC/Clang warnings, he uses the following:
-Wundef
-Wmissing-prototypes
-Wmissing-declarations
-Wmissing-format-attribute
-Wnested-externs
-Wcast-align
-Wpointer-arith
-Wreturn-type
-Wswitch
-Wshadow
-Wcast-qual
-Wwrite-strings
-Wformat=2
-Wpointer-sign
-Wmissing-noreturn
With these settings, unit_tests.c generates the following warnings:
unit_tests.c:53:7: warning: no previous prototype for 'unreliable_tracking_malloc' [-Wmissing-prototypes]
53 | void *unreliable_tracking_malloc( size_t size )
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
unit_tests.c:71:6: warning: no previous prototype for 'tracking_free' [-Wmissing-prototypes]
71 | void tracking_free( void *ptr, size_t size )
| ^~~~~~~~~~~~~
unit_tests.c:90:7: warning: no previous prototype for 'unreliable_tracking_malloc_with_ctx' [-Wmissing-prototypes]
90 | void *unreliable_tracking_malloc_with_ctx( size_t size, context *ctx )
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
unit_tests.c:101:6: warning: no previous prototype for 'tracking_free_with_ctx' [-Wmissing-prototypes]
101 | void tracking_free_with_ctx( void *ptr, size_t size, context *ctx )
| ^~~~~~~~~~~~~~~~~~~~~~
unit_tests.c:111:6: warning: no previous prototype for 'dtor' [-Wmissing-prototypes]
111 | void dtor( uint64_t key_or_val )
| ^~~~
unit_tests.c:116:6: warning: no previous prototype for 'check_dtors_arr' [-Wmissing-prototypes]
116 | void check_dtors_arr( void )
| ^~~~~~~~~~~~~~~
In file included from unit_tests.c:137:
../verstable.h: In function 'integer_map_init':
../verstable.h:906:21: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
906 | table->metadata = (uint16_t *)&vt_empty_placeholder_metadatum;
| ^
../verstable.h: In function 'integer_map_init_clone':
../verstable.h:952:23: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
952 | table->metadata = (uint16_t *)&vt_empty_placeholder_metadatum;
| ^
../verstable.h: In function 'integer_map_shrink':
../verstable.h:1637:23: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
1637 | table->metadata = (uint16_t *)&vt_empty_placeholder_metadatum;
| ^
In file included from unit_tests.c:147:
../verstable.h: In function 'integer_dtors_map_init':
../verstable.h:906:21: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
906 | table->metadata = (uint16_t *)&vt_empty_placeholder_metadatum;
| ^
../verstable.h: In function 'integer_dtors_map_init_clone':
../verstable.h:952:23: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
952 | table->metadata = (uint16_t *)&vt_empty_placeholder_metadatum;
| ^
../verstable.h: In function 'integer_dtors_map_shrink':
../verstable.h:1637:23: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
1637 | table->metadata = (uint16_t *)&vt_empty_placeholder_metadatum;
| ^
In file included from unit_tests.c:155:
../verstable.h: In function 'string_map_init':
../verstable.h:906:21: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
906 | table->metadata = (uint16_t *)&vt_empty_placeholder_metadatum;
| ^
../verstable.h: In function 'string_map_init_clone':
../verstable.h:952:23: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
952 | table->metadata = (uint16_t *)&vt_empty_placeholder_metadatum;
| ^
../verstable.h: In function 'string_map_shrink':
../verstable.h:1637:23: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
1637 | table->metadata = (uint16_t *)&vt_empty_placeholder_metadatum;
| ^
In file included from unit_tests.c:162:
../verstable.h: In function 'integer_set_init':
../verstable.h:906:21: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
906 | table->metadata = (uint16_t *)&vt_empty_placeholder_metadatum;
| ^
../verstable.h: In function 'integer_set_init_clone':
../verstable.h:952:23: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
952 | table->metadata = (uint16_t *)&vt_empty_placeholder_metadatum;
| ^
../verstable.h: In function 'integer_set_shrink':
../verstable.h:1637:23: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
1637 | table->metadata = (uint16_t *)&vt_empty_placeholder_metadatum;
| ^
In file included from unit_tests.c:170:
../verstable.h: In function 'integer_dtors_set_init':
../verstable.h:906:21: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
906 | table->metadata = (uint16_t *)&vt_empty_placeholder_metadatum;
| ^
../verstable.h: In function 'integer_dtors_set_init_clone':
../verstable.h:952:23: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
952 | table->metadata = (uint16_t *)&vt_empty_placeholder_metadatum;
| ^
../verstable.h: In function 'integer_dtors_set_shrink':
../verstable.h:1637:23: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
1637 | table->metadata = (uint16_t *)&vt_empty_placeholder_metadatum;
| ^
In file included from unit_tests.c:177:
../verstable.h: In function 'string_set_init':
../verstable.h:906:21: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
906 | table->metadata = (uint16_t *)&vt_empty_placeholder_metadatum;
| ^
../verstable.h: In function 'string_set_init_clone':
../verstable.h:952:23: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
952 | table->metadata = (uint16_t *)&vt_empty_placeholder_metadatum;
| ^
../verstable.h: In function 'string_set_shrink':
../verstable.h:1637:23: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
1637 | table->metadata = (uint16_t *)&vt_empty_placeholder_metadatum;
| ^
In file included from unit_tests.c:186:
../verstable.h: In function 'integer_map_with_ctx_init':
../verstable.h:906:21: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
906 | table->metadata = (uint16_t *)&vt_empty_placeholder_metadatum;
| ^
../verstable.h: In function 'integer_map_with_ctx_init_clone':
../verstable.h:952:23: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
952 | table->metadata = (uint16_t *)&vt_empty_placeholder_metadatum;
| ^
../verstable.h: In function 'integer_map_with_ctx_shrink':
../verstable.h:1637:23: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
1637 | table->metadata = (uint16_t *)&vt_empty_placeholder_metadatum;
| ^
In file included from unit_tests.c:194:
../verstable.h: In function 'integer_set_with_ctx_init':
../verstable.h:906:21: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
906 | table->metadata = (uint16_t *)&vt_empty_placeholder_metadatum;
| ^
../verstable.h: In function 'integer_set_with_ctx_init_clone':
../verstable.h:952:23: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
952 | table->metadata = (uint16_t *)&vt_empty_placeholder_metadatum;
| ^
../verstable.h: In function 'integer_set_with_ctx_shrink':
../verstable.h:1637:23: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
1637 | table->metadata = (uint16_t *)&vt_empty_placeholder_metadatum;
| ^
unit_tests.c: At top level:
unit_tests.c:198:6: warning: no previous prototype for 'test_map_reserve' [-Wmissing-prototypes]
198 | void test_map_reserve( void )
| ^~~~~~~~~~~~~~~~
unit_tests.c:240:6: warning: no previous prototype for 'test_map_shrink' [-Wmissing-prototypes]
240 | void test_map_shrink( void )
| ^~~~~~~~~~~~~~~
unit_tests.c:287:6: warning: no previous prototype for 'test_map_insert' [-Wmissing-prototypes]
287 | void test_map_insert( void )
| ^~~~~~~~~~~~~~~
unit_tests.c:319:6: warning: no previous prototype for 'test_map_get_or_insert' [-Wmissing-prototypes]
319 | void test_map_get_or_insert( void )
| ^~~~~~~~~~~~~~~~~~~~~~
unit_tests.c:354:6: warning: no previous prototype for 'test_map_get' [-Wmissing-prototypes]
354 | void test_map_get( void )
| ^~~~~~~~~~~~
unit_tests.c:380:6: warning: no previous prototype for 'test_map_erase' [-Wmissing-prototypes]
380 | void test_map_erase( void )
| ^~~~~~~~~~~~~~
unit_tests.c:414:6: warning: no previous prototype for 'test_map_erase_itr' [-Wmissing-prototypes]
414 | void test_map_erase_itr( void )
| ^~~~~~~~~~~~~~~~~~
unit_tests.c:473:6: warning: no previous prototype for 'test_map_clear' [-Wmissing-prototypes]
473 | void test_map_clear( void )
| ^~~~~~~~~~~~~~
unit_tests.c:504:6: warning: no previous prototype for 'test_map_cleanup' [-Wmissing-prototypes]
504 | void test_map_cleanup( void )
| ^~~~~~~~~~~~~~~~
unit_tests.c:534:6: warning: no previous prototype for 'test_map_init_clone' [-Wmissing-prototypes]
534 | void test_map_init_clone( void )
| ^~~~~~~~~~~~~~~~~~~
unit_tests.c:563:6: warning: no previous prototype for 'test_map_iteration' [-Wmissing-prototypes]
563 | void test_map_iteration( void )
| ^~~~~~~~~~~~~~~~~~
unit_tests.c:600:6: warning: no previous prototype for 'test_map_dtors' [-Wmissing-prototypes]
600 | void test_map_dtors( void )
| ^~~~~~~~~~~~~~
unit_tests.c:638:6: warning: no previous prototype for 'test_map_strings' [-Wmissing-prototypes]
638 | void test_map_strings( void )
| ^~~~~~~~~~~~~~~~
unit_tests.c: In function 'test_map_strings':
unit_tests.c:646:57: warning: passing argument 2 of 'vt_insert_0002' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
646 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_map, "This", "is" ) ) );
| ^~~~~~
unit_tests.c:42:38: note: in definition of macro 'UNTIL_SUCCESS'
42 | #define UNTIL_SUCCESS( xp ) while( !(xp) )
| ^~
unit_tests.c:646:19: note: in expansion of macro 'vt_is_end'
646 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_map, "This", "is" ) ) );
| ^~~~~~~~~
unit_tests.c:646:36: note: in expansion of macro 'vt_insert'
646 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_map, "This", "is" ) ) );
| ^~~~~~~~~
../verstable.h:1765:10: note: expected 'char *' but argument is of type 'const char *'
1765 | KEY_TY key
unit_tests.c:646:65: warning: passing argument 3 of 'vt_insert_0002' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
646 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_map, "This", "is" ) ) );
| ^~~~
unit_tests.c:42:38: note: in definition of macro 'UNTIL_SUCCESS'
42 | #define UNTIL_SUCCESS( xp ) while( !(xp) )
| ^~
unit_tests.c:646:19: note: in expansion of macro 'vt_is_end'
646 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_map, "This", "is" ) ) );
| ^~~~~~~~~
unit_tests.c:646:36: note: in expansion of macro 'vt_insert'
646 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_map, "This", "is" ) ) );
| ^~~~~~~~~
../verstable.h:1767:12: note: expected 'char *' but argument is of type 'const char *'
1767 | , VAL_TY val
unit_tests.c:646:57: warning: passing argument 2 of 'vt_insert_0002' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
646 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_map, "This", "is" ) ) );
| ^~~~~~
unit_tests.c:42:38: note: in definition of macro 'UNTIL_SUCCESS'
42 | #define UNTIL_SUCCESS( xp ) while( !(xp) )
| ^~
unit_tests.c:646:19: note: in expansion of macro 'vt_is_end'
646 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_map, "This", "is" ) ) );
| ^~~~~~~~~
unit_tests.c:646:36: note: in expansion of macro 'vt_insert'
646 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_map, "This", "is" ) ) );
| ^~~~~~~~~
../verstable.h:1765:10: note: expected 'char *' but argument is of type 'const char *'
1765 | KEY_TY key
unit_tests.c:646:65: warning: passing argument 3 of 'vt_insert_0002' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
646 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_map, "This", "is" ) ) );
| ^~~~
unit_tests.c:42:38: note: in definition of macro 'UNTIL_SUCCESS'
42 | #define UNTIL_SUCCESS( xp ) while( !(xp) )
| ^~
unit_tests.c:646:19: note: in expansion of macro 'vt_is_end'
646 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_map, "This", "is" ) ) );
| ^~~~~~~~~
unit_tests.c:646:36: note: in expansion of macro 'vt_insert'
646 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_map, "This", "is" ) ) );
| ^~~~~~~~~
../verstable.h:1767:12: note: expected 'char *' but argument is of type 'const char *'
1767 | , VAL_TY val
unit_tests.c:648:64: warning: passing argument 2 of 'vt_get_or_insert_0002' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
648 | UNTIL_SUCCESS( !vt_is_end( itr = vt_get_or_insert( &our_map, "a", "test" ) ) );
| ^~~
unit_tests.c:42:38: note: in definition of macro 'UNTIL_SUCCESS'
42 | #define UNTIL_SUCCESS( xp ) while( !(xp) )
| ^~
unit_tests.c:648:19: note: in expansion of macro 'vt_is_end'
648 | UNTIL_SUCCESS( !vt_is_end( itr = vt_get_or_insert( &our_map, "a", "test" ) ) );
| ^~~~~~~~~
unit_tests.c:648:36: note: in expansion of macro 'vt_get_or_insert'
648 | UNTIL_SUCCESS( !vt_is_end( itr = vt_get_or_insert( &our_map, "a", "test" ) ) );
| ^~~~~~~~~~~~~~~~
../verstable.h:1782:10: note: expected 'char *' but argument is of type 'const char *'
1782 | KEY_TY key
unit_tests.c:648:69: warning: passing argument 3 of 'vt_get_or_insert_0002' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
648 | UNTIL_SUCCESS( !vt_is_end( itr = vt_get_or_insert( &our_map, "a", "test" ) ) );
| ^~~~~~
unit_tests.c:42:38: note: in definition of macro 'UNTIL_SUCCESS'
42 | #define UNTIL_SUCCESS( xp ) while( !(xp) )
| ^~
unit_tests.c:648:19: note: in expansion of macro 'vt_is_end'
648 | UNTIL_SUCCESS( !vt_is_end( itr = vt_get_or_insert( &our_map, "a", "test" ) ) );
| ^~~~~~~~~
unit_tests.c:648:36: note: in expansion of macro 'vt_get_or_insert'
648 | UNTIL_SUCCESS( !vt_is_end( itr = vt_get_or_insert( &our_map, "a", "test" ) ) );
| ^~~~~~~~~~~~~~~~
../verstable.h:1784:12: note: expected 'char *' but argument is of type 'const char *'
1784 | , VAL_TY val
unit_tests.c:648:64: warning: passing argument 2 of 'vt_get_or_insert_0002' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
648 | UNTIL_SUCCESS( !vt_is_end( itr = vt_get_or_insert( &our_map, "a", "test" ) ) );
| ^~~
unit_tests.c:42:38: note: in definition of macro 'UNTIL_SUCCESS'
42 | #define UNTIL_SUCCESS( xp ) while( !(xp) )
| ^~
unit_tests.c:648:19: note: in expansion of macro 'vt_is_end'
648 | UNTIL_SUCCESS( !vt_is_end( itr = vt_get_or_insert( &our_map, "a", "test" ) ) );
| ^~~~~~~~~
unit_tests.c:648:36: note: in expansion of macro 'vt_get_or_insert'
648 | UNTIL_SUCCESS( !vt_is_end( itr = vt_get_or_insert( &our_map, "a", "test" ) ) );
| ^~~~~~~~~~~~~~~~
../verstable.h:1782:10: note: expected 'char *' but argument is of type 'const char *'
1782 | KEY_TY key
unit_tests.c:648:69: warning: passing argument 3 of 'vt_get_or_insert_0002' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
648 | UNTIL_SUCCESS( !vt_is_end( itr = vt_get_or_insert( &our_map, "a", "test" ) ) );
| ^~~~~~
unit_tests.c:42:38: note: in definition of macro 'UNTIL_SUCCESS'
42 | #define UNTIL_SUCCESS( xp ) while( !(xp) )
| ^~
unit_tests.c:648:19: note: in expansion of macro 'vt_is_end'
648 | UNTIL_SUCCESS( !vt_is_end( itr = vt_get_or_insert( &our_map, "a", "test" ) ) );
| ^~~~~~~~~
unit_tests.c:648:36: note: in expansion of macro 'vt_get_or_insert'
648 | UNTIL_SUCCESS( !vt_is_end( itr = vt_get_or_insert( &our_map, "a", "test" ) ) );
| ^~~~~~~~~~~~~~~~
../verstable.h:1784:12: note: expected 'char *' but argument is of type 'const char *'
1784 | , VAL_TY val
unit_tests.c:664:44: warning: passing argument 2 of 'vt_get_0002' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
664 | ALWAYS_ASSERT( strcmp( vt_get( &our_map, "This" ).data->val, "is" ) == 0 );
| ^~~~~~
unit_tests.c:35:4: note: in definition of macro 'ALWAYS_ASSERT'
35 | ( (xp) ? (void)0 : ( fprintf( stderr, "Assertion failed at line %d: %s\n", __LINE__, #xp ), exit( 0 ) ) ) \
| ^~
unit_tests.c:664:26: note: in expansion of macro 'vt_get'
664 | ALWAYS_ASSERT( strcmp( vt_get( &our_map, "This" ).data->val, "is" ) == 0 );
| ^~~~~~
../verstable.h:1797:94: note: expected 'char *' but argument is of type 'const char *'
1797 | static inline VT_CAT( NAME, _itr ) VT_CAT( vt_get_, VT_TEMPLATE_COUNT )( NAME *table, KEY_TY key )
unit_tests.c:665:44: warning: passing argument 2 of 'vt_get_0002' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
665 | ALWAYS_ASSERT( strcmp( vt_get( &our_map, "a" ).data->val, "test" ) == 0 );
| ^~~
unit_tests.c:35:4: note: in definition of macro 'ALWAYS_ASSERT'
35 | ( (xp) ? (void)0 : ( fprintf( stderr, "Assertion failed at line %d: %s\n", __LINE__, #xp ), exit( 0 ) ) ) \
| ^~
unit_tests.c:665:26: note: in expansion of macro 'vt_get'
665 | ALWAYS_ASSERT( strcmp( vt_get( &our_map, "a" ).data->val, "test" ) == 0 );
| ^~~~~~
../verstable.h:1797:94: note: expected 'char *' but argument is of type 'const char *'
1797 | static inline VT_CAT( NAME, _itr ) VT_CAT( vt_get_, VT_TEMPLATE_COUNT )( NAME *table, KEY_TY key )
unit_tests.c:673:23: warning: passing argument 2 of 'vt_erase_0002' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
673 | vt_erase( &our_map, "This" );
| ^~~~~~
../verstable.h:672:104: note: in definition of macro 'vt_erase'
672 | #define vt_erase( table, ... ) _Generic( *( table ) VT_GENERIC_SLOTS( vt_table_, vt_erase_ ) )( table, __VA_ARGS__ )
| ^~~~~~~~~~~
../verstable.h:1802:80: note: expected 'char *' but argument is of type 'const char *'
1802 | static inline bool VT_CAT( vt_erase_, VT_TEMPLATE_COUNT )( NAME *table, KEY_TY key )
unit_tests.c: At top level:
unit_tests.c:688:6: warning: no previous prototype for 'test_map_with_ctx' [-Wmissing-prototypes]
688 | void test_map_with_ctx( void )
| ^~~~~~~~~~~~~~~~~
unit_tests.c:727:6: warning: no previous prototype for 'test_set_reserve' [-Wmissing-prototypes]
727 | void test_set_reserve( void )
| ^~~~~~~~~~~~~~~~
unit_tests.c:769:6: warning: no previous prototype for 'test_set_shrink' [-Wmissing-prototypes]
769 | void test_set_shrink( void )
| ^~~~~~~~~~~~~~~
unit_tests.c:816:6: warning: no previous prototype for 'test_set_insert' [-Wmissing-prototypes]
816 | void test_set_insert( void )
| ^~~~~~~~~~~~~~~
unit_tests.c:848:6: warning: no previous prototype for 'test_set_get_or_insert' [-Wmissing-prototypes]
848 | void test_set_get_or_insert( void )
| ^~~~~~~~~~~~~~~~~~~~~~
unit_tests.c:883:6: warning: no previous prototype for 'test_set_get' [-Wmissing-prototypes]
883 | void test_set_get( void )
| ^~~~~~~~~~~~
unit_tests.c:909:6: warning: no previous prototype for 'test_set_erase' [-Wmissing-prototypes]
909 | void test_set_erase( void )
| ^~~~~~~~~~~~~~
unit_tests.c:943:6: warning: no previous prototype for 'test_set_erase_itr' [-Wmissing-prototypes]
943 | void test_set_erase_itr( void )
| ^~~~~~~~~~~~~~~~~~
unit_tests.c:1002:6: warning: no previous prototype for 'test_set_clear' [-Wmissing-prototypes]
1002 | void test_set_clear( void )
| ^~~~~~~~~~~~~~
unit_tests.c:1033:6: warning: no previous prototype for 'test_set_cleanup' [-Wmissing-prototypes]
1033 | void test_set_cleanup( void )
| ^~~~~~~~~~~~~~~~
unit_tests.c:1063:6: warning: no previous prototype for 'test_set_init_clone' [-Wmissing-prototypes]
1063 | void test_set_init_clone( void )
| ^~~~~~~~~~~~~~~~~~~
unit_tests.c:1092:6: warning: no previous prototype for 'test_set_iteration' [-Wmissing-prototypes]
1092 | void test_set_iteration( void )
| ^~~~~~~~~~~~~~~~~~
unit_tests.c:1129:6: warning: no previous prototype for 'test_set_dtors' [-Wmissing-prototypes]
1129 | void test_set_dtors( void )
| ^~~~~~~~~~~~~~
unit_tests.c:1166:6: warning: no previous prototype for 'test_set_strings' [-Wmissing-prototypes]
1166 | void test_set_strings( void )
| ^~~~~~~~~~~~~~~~
unit_tests.c: In function 'test_set_strings':
unit_tests.c:1174:57: warning: passing argument 2 of 'vt_insert_0005' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1174 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_set, "This" ) ) );
| ^~~~~~
unit_tests.c:42:38: note: in definition of macro 'UNTIL_SUCCESS'
42 | #define UNTIL_SUCCESS( xp ) while( !(xp) )
| ^~
unit_tests.c:1174:19: note: in expansion of macro 'vt_is_end'
1174 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_set, "This" ) ) );
| ^~~~~~~~~
unit_tests.c:1174:36: note: in expansion of macro 'vt_insert'
1174 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_set, "This" ) ) );
| ^~~~~~~~~
../verstable.h:1765:10: note: expected 'char *' but argument is of type 'const char *'
1765 | KEY_TY key
unit_tests.c:1174:57: warning: passing argument 2 of 'vt_insert_0005' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1174 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_set, "This" ) ) );
| ^~~~~~
unit_tests.c:42:38: note: in definition of macro 'UNTIL_SUCCESS'
42 | #define UNTIL_SUCCESS( xp ) while( !(xp) )
| ^~
unit_tests.c:1174:19: note: in expansion of macro 'vt_is_end'
1174 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_set, "This" ) ) );
| ^~~~~~~~~
unit_tests.c:1174:36: note: in expansion of macro 'vt_insert'
1174 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_set, "This" ) ) );
| ^~~~~~~~~
../verstable.h:1765:10: note: expected 'char *' but argument is of type 'const char *'
1765 | KEY_TY key
unit_tests.c:1176:57: warning: passing argument 2 of 'vt_insert_0005' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1176 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_set, "is" ) ) );
| ^~~~
unit_tests.c:42:38: note: in definition of macro 'UNTIL_SUCCESS'
42 | #define UNTIL_SUCCESS( xp ) while( !(xp) )
| ^~
unit_tests.c:1176:19: note: in expansion of macro 'vt_is_end'
1176 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_set, "is" ) ) );
| ^~~~~~~~~
unit_tests.c:1176:36: note: in expansion of macro 'vt_insert'
1176 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_set, "is" ) ) );
| ^~~~~~~~~
../verstable.h:1765:10: note: expected 'char *' but argument is of type 'const char *'
1765 | KEY_TY key
unit_tests.c:1176:57: warning: passing argument 2 of 'vt_insert_0005' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1176 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_set, "is" ) ) );
| ^~~~
unit_tests.c:42:38: note: in definition of macro 'UNTIL_SUCCESS'
42 | #define UNTIL_SUCCESS( xp ) while( !(xp) )
| ^~
unit_tests.c:1176:19: note: in expansion of macro 'vt_is_end'
1176 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_set, "is" ) ) );
| ^~~~~~~~~
unit_tests.c:1176:36: note: in expansion of macro 'vt_insert'
1176 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_set, "is" ) ) );
| ^~~~~~~~~
../verstable.h:1765:10: note: expected 'char *' but argument is of type 'const char *'
1765 | KEY_TY key
unit_tests.c:1178:57: warning: passing argument 2 of 'vt_insert_0005' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1178 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_set, "a" ) ) );
| ^~~
unit_tests.c:42:38: note: in definition of macro 'UNTIL_SUCCESS'
42 | #define UNTIL_SUCCESS( xp ) while( !(xp) )
| ^~
unit_tests.c:1178:19: note: in expansion of macro 'vt_is_end'
1178 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_set, "a" ) ) );
| ^~~~~~~~~
unit_tests.c:1178:36: note: in expansion of macro 'vt_insert'
1178 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_set, "a" ) ) );
| ^~~~~~~~~
../verstable.h:1765:10: note: expected 'char *' but argument is of type 'const char *'
1765 | KEY_TY key
unit_tests.c:1178:57: warning: passing argument 2 of 'vt_insert_0005' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1178 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_set, "a" ) ) );
| ^~~
unit_tests.c:42:38: note: in definition of macro 'UNTIL_SUCCESS'
42 | #define UNTIL_SUCCESS( xp ) while( !(xp) )
| ^~
unit_tests.c:1178:19: note: in expansion of macro 'vt_is_end'
1178 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_set, "a" ) ) );
| ^~~~~~~~~
unit_tests.c:1178:36: note: in expansion of macro 'vt_insert'
1178 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_set, "a" ) ) );
| ^~~~~~~~~
../verstable.h:1765:10: note: expected 'char *' but argument is of type 'const char *'
1765 | KEY_TY key
unit_tests.c:1180:57: warning: passing argument 2 of 'vt_insert_0005' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1180 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_set, "test" ) ) );
| ^~~~~~
unit_tests.c:42:38: note: in definition of macro 'UNTIL_SUCCESS'
42 | #define UNTIL_SUCCESS( xp ) while( !(xp) )
| ^~
unit_tests.c:1180:19: note: in expansion of macro 'vt_is_end'
1180 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_set, "test" ) ) );
| ^~~~~~~~~
unit_tests.c:1180:36: note: in expansion of macro 'vt_insert'
1180 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_set, "test" ) ) );
| ^~~~~~~~~
../verstable.h:1765:10: note: expected 'char *' but argument is of type 'const char *'
1765 | KEY_TY key
unit_tests.c:1180:57: warning: passing argument 2 of 'vt_insert_0005' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1180 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_set, "test" ) ) );
| ^~~~~~
unit_tests.c:42:38: note: in definition of macro 'UNTIL_SUCCESS'
42 | #define UNTIL_SUCCESS( xp ) while( !(xp) )
| ^~
unit_tests.c:1180:19: note: in expansion of macro 'vt_is_end'
1180 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_set, "test" ) ) );
| ^~~~~~~~~
unit_tests.c:1180:36: note: in expansion of macro 'vt_insert'
1180 | UNTIL_SUCCESS( !vt_is_end( itr = vt_insert( &our_set, "test" ) ) );
| ^~~~~~~~~
../verstable.h:1765:10: note: expected 'char *' but argument is of type 'const char *'
1765 | KEY_TY key
unit_tests.c:1200:44: warning: passing argument 2 of 'vt_get_0005' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1200 | ALWAYS_ASSERT( strcmp( vt_get( &our_set, "This" ).data->key, "This" ) == 0 );
| ^~~~~~
unit_tests.c:35:4: note: in definition of macro 'ALWAYS_ASSERT'
35 | ( (xp) ? (void)0 : ( fprintf( stderr, "Assertion failed at line %d: %s\n", __LINE__, #xp ), exit( 0 ) ) ) \
| ^~
unit_tests.c:1200:26: note: in expansion of macro 'vt_get'
1200 | ALWAYS_ASSERT( strcmp( vt_get( &our_set, "This" ).data->key, "This" ) == 0 );
| ^~~~~~
../verstable.h:1797:94: note: expected 'char *' but argument is of type 'const char *'
1797 | static inline VT_CAT( NAME, _itr ) VT_CAT( vt_get_, VT_TEMPLATE_COUNT )( NAME *table, KEY_TY key )
unit_tests.c:1201:44: warning: passing argument 2 of 'vt_get_0005' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1201 | ALWAYS_ASSERT( strcmp( vt_get( &our_set, "is" ).data->key, "is" ) == 0 );
| ^~~~
unit_tests.c:35:4: note: in definition of macro 'ALWAYS_ASSERT'
35 | ( (xp) ? (void)0 : ( fprintf( stderr, "Assertion failed at line %d: %s\n", __LINE__, #xp ), exit( 0 ) ) ) \
| ^~
unit_tests.c:1201:26: note: in expansion of macro 'vt_get'
1201 | ALWAYS_ASSERT( strcmp( vt_get( &our_set, "is" ).data->key, "is" ) == 0 );
| ^~~~~~
../verstable.h:1797:94: note: expected 'char *' but argument is of type 'const char *'
1797 | static inline VT_CAT( NAME, _itr ) VT_CAT( vt_get_, VT_TEMPLATE_COUNT )( NAME *table, KEY_TY key )
unit_tests.c:1202:44: warning: passing argument 2 of 'vt_get_0005' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1202 | ALWAYS_ASSERT( strcmp( vt_get( &our_set, "a" ).data->key, "a" ) == 0 );
| ^~~
unit_tests.c:35:4: note: in definition of macro 'ALWAYS_ASSERT'
35 | ( (xp) ? (void)0 : ( fprintf( stderr, "Assertion failed at line %d: %s\n", __LINE__, #xp ), exit( 0 ) ) ) \
| ^~
unit_tests.c:1202:26: note: in expansion of macro 'vt_get'
1202 | ALWAYS_ASSERT( strcmp( vt_get( &our_set, "a" ).data->key, "a" ) == 0 );
| ^~~~~~
../verstable.h:1797:94: note: expected 'char *' but argument is of type 'const char *'
1797 | static inline VT_CAT( NAME, _itr ) VT_CAT( vt_get_, VT_TEMPLATE_COUNT )( NAME *table, KEY_TY key )
unit_tests.c:1203:44: warning: passing argument 2 of 'vt_get_0005' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1203 | ALWAYS_ASSERT( strcmp( vt_get( &our_set, "test" ).data->key, "test" ) == 0 );
| ^~~~~~
unit_tests.c:35:4: note: in definition of macro 'ALWAYS_ASSERT'
35 | ( (xp) ? (void)0 : ( fprintf( stderr, "Assertion failed at line %d: %s\n", __LINE__, #xp ), exit( 0 ) ) ) \
| ^~
unit_tests.c:1203:26: note: in expansion of macro 'vt_get'
1203 | ALWAYS_ASSERT( strcmp( vt_get( &our_set, "test" ).data->key, "test" ) == 0 );
| ^~~~~~
../verstable.h:1797:94: note: expected 'char *' but argument is of type 'const char *'
1797 | static inline VT_CAT( NAME, _itr ) VT_CAT( vt_get_, VT_TEMPLATE_COUNT )( NAME *table, KEY_TY key )
unit_tests.c:1204:44: warning: passing argument 2 of 'vt_get_0005' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1204 | ALWAYS_ASSERT( strcmp( vt_get( &our_set, "of" ).data->key, str_1 ) == 0 );
| ^~~~
unit_tests.c:35:4: note: in definition of macro 'ALWAYS_ASSERT'
35 | ( (xp) ? (void)0 : ( fprintf( stderr, "Assertion failed at line %d: %s\n", __LINE__, #xp ), exit( 0 ) ) ) \
| ^~
unit_tests.c:1204:26: note: in expansion of macro 'vt_get'
1204 | ALWAYS_ASSERT( strcmp( vt_get( &our_set, "of" ).data->key, str_1 ) == 0 );
| ^~~~~~
../verstable.h:1797:94: note: expected 'char *' but argument is of type 'const char *'
1797 | static inline VT_CAT( NAME, _itr ) VT_CAT( vt_get_, VT_TEMPLATE_COUNT )( NAME *table, KEY_TY key )
unit_tests.c:1205:44: warning: passing argument 2 of 'vt_get_0005' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1205 | ALWAYS_ASSERT( strcmp( vt_get( &our_set, "sets" ).data->key, str_2 ) == 0 );
| ^~~~~~
unit_tests.c:35:4: note: in definition of macro 'ALWAYS_ASSERT'
35 | ( (xp) ? (void)0 : ( fprintf( stderr, "Assertion failed at line %d: %s\n", __LINE__, #xp ), exit( 0 ) ) ) \
| ^~
unit_tests.c:1205:26: note: in expansion of macro 'vt_get'
1205 | ALWAYS_ASSERT( strcmp( vt_get( &our_set, "sets" ).data->key, str_2 ) == 0 );
| ^~~~~~
../verstable.h:1797:94: note: expected 'char *' but argument is of type 'const char *'
1797 | static inline VT_CAT( NAME, _itr ) VT_CAT( vt_get_, VT_TEMPLATE_COUNT )( NAME *table, KEY_TY key )
unit_tests.c:1206:44: warning: passing argument 2 of 'vt_get_0005' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1206 | ALWAYS_ASSERT( strcmp( vt_get( &our_set, "with" ).data->key, str_3 ) == 0 );
| ^~~~~~
unit_tests.c:35:4: note: in definition of macro 'ALWAYS_ASSERT'
35 | ( (xp) ? (void)0 : ( fprintf( stderr, "Assertion failed at line %d: %s\n", __LINE__, #xp ), exit( 0 ) ) ) \
| ^~
unit_tests.c:1206:26: note: in expansion of macro 'vt_get'
1206 | ALWAYS_ASSERT( strcmp( vt_get( &our_set, "with" ).data->key, str_3 ) == 0 );
| ^~~~~~
../verstable.h:1797:94: note: expected 'char *' but argument is of type 'const char *'
1797 | static inline VT_CAT( NAME, _itr ) VT_CAT( vt_get_, VT_TEMPLATE_COUNT )( NAME *table, KEY_TY key )
unit_tests.c:1207:44: warning: passing argument 2 of 'vt_get_0005' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1207 | ALWAYS_ASSERT( strcmp( vt_get( &our_set, "strings" ).data->key, str_4 ) == 0 );
| ^~~~~~~~~
unit_tests.c:35:4: note: in definition of macro 'ALWAYS_ASSERT'
35 | ( (xp) ? (void)0 : ( fprintf( stderr, "Assertion failed at line %d: %s\n", __LINE__, #xp ), exit( 0 ) ) ) \
| ^~
unit_tests.c:1207:26: note: in expansion of macro 'vt_get'
1207 | ALWAYS_ASSERT( strcmp( vt_get( &our_set, "strings" ).data->key, str_4 ) == 0 );
| ^~~~~~
../verstable.h:1797:94: note: expected 'char *' but argument is of type 'const char *'
1797 | static inline VT_CAT( NAME, _itr ) VT_CAT( vt_get_, VT_TEMPLATE_COUNT )( NAME *table, KEY_TY key )
unit_tests.c: At top level:
unit_tests.c:1212:6: warning: no previous prototype for 'test_set_with_ctx' [-Wmissing-prototypes]
1212 | void test_set_with_ctx( void )
| ^~~~~~~~~~~~~~~~~
So at present and with these settings, GCC (and probably Clang) is complaining about the following:
-Wmissing-prototypesfor functions inunit_tests.c. In my view, these warnings (and, by extension, this flag) are rather extreme. These functions are ordered such that they don't require prototypes. Nevertheless, the warnings could perhaps be silenced by (superfluously) defining these functions asstatic.-Wcast-qualfor the various occurrences oftable->metadata = (uint16_t *)&vt_empty_placeholder_metadatum;inverstable.h. Theuint16_t *cast here is included specifically for the purpose of discardingconst. @rsmarples has suggested that the warning can be silenced via an intermediate cast tovoid *. However, if we are to support-Wcast-qual, I would prefer explicitly disabling the warning via#pragma GCC diagnostic ignoredover thevoid *workaround, which isn't as clear and isn't guaranteed to work in the long term.-Wdiscarded-qualifiersfor the calls to hash-table functions inunit_tests.hwhen the key argument is an (implicitlyconst) string literal. This warning probably occurs when anyconstpointer is passed as a key or value into hash-table functions. Supporting it would require introducingconstcorrectness into function parameters throughout the library (possibly also for thetableargument), which would be a major quality improvement.
I've opened the issue to centralize discussion and create a space for users to request support for other diagnostic flags.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request