Fwd: New Defects reported by Coverity Scan for RTEMS
Sebastian Huber
sebastian.huber at embedded-brains.de
Wed Dec 9 09:56:53 UTC 2020
On 09/12/2020 10:11, Sebastian Huber wrote:
> On 08/12/2020 19:10, Gedare Bloom wrote:
>
>>
>> Hi all,
>>
>> I get a text report on new defects from Coverity. I don't know how I
>> managed to sign up for it, and I'm not sure I can get it sent to any
>> list automatically, but here is the current updated new defects. Just
>> looks like two new ones related to static assertions.
>>
>> ---------- Forwarded message ---------
>> From: <scan-admin at coverity.com <mailto:scan-admin at coverity.com>>
>> Date: Mon, Dec 7, 2020 at 7:38 AM
>> Subject: New Defects reported by Coverity Scan for RTEMS
>> To: <gedare at gwmail.gwu.edu <mailto:gedare at gwmail.gwu.edu>>
>>
>>
>> Hi,
>>
>> Please find the latest report on new defect(s) introduced to RTEMS
>> found with Coverity Scan.
>>
>> 1 new defect(s) introduced to RTEMS found with Coverity Scan.
>> 10 defect(s), reported by Coverity Scan earlier, were marked fixed in
>> the recent build analyzed by Coverity Scan.
>>
>> New defect(s) Reported-by: Coverity Scan
>> Showing 1 of 1 defect(s)
>>
>>
>> ** CID 1470570: (PARSE_ERROR)
>> /cpukit/include/rtems/confdefs/inittask.h: 110 in ()
>> /cpukit/include/rtems/confdefs/inittask.h: 110 in ()
>>
>>
>> ________________________________________________________________________________________________________
>>
>> *** CID 1470570: (PARSE_ERROR)
>> /cpukit/include/rtems/confdefs/inittask.h: 110 in ()
>> 104 */
>> 105 #pragma GCC diagnostic push
>> 106 #pragma GCC diagnostic ignored "-Waddress"
>> 107 #pragma GCC diagnostic ignored "-Wpragmas"
>> 108 #pragma GCC diagnostic ignored "-Wtautological-pointer-compare"
>> 109
>> >>> CID 1470570: (PARSE_ERROR)
>> >>> type of cast must be integral
>> 110 RTEMS_STATIC_ASSERT(
>> 111 CONFIGURE_INIT_TASK_ENTRY_POINT != NULL,
>> 112 CONFIGURE_INIT_TASK_ENTRY_POINT_MUST_NOT_BE_NULL
>> 113 );
>> 114
>> 115 #pragma GCC diagnostic pop
>> /cpukit/include/rtems/confdefs/inittask.h: 110 in ()
>> 104 */
>> 105 #pragma GCC diagnostic push
>> 106 #pragma GCC diagnostic ignored "-Waddress"
>> 107 #pragma GCC diagnostic ignored "-Wpragmas"
>> 108 #pragma GCC diagnostic ignored "-Wtautological-pointer-compare"
>> 109
>> >>> CID 1470570: (PARSE_ERROR)
>> >>> expression must be an integral constant expression
>> 110 RTEMS_STATIC_ASSERT(
>> 111 CONFIGURE_INIT_TASK_ENTRY_POINT != NULL,
>> 112 CONFIGURE_INIT_TASK_ENTRY_POINT_MUST_NOT_BE_NULL
>> 113 );
>> 114
>> 115 #pragma GCC diagnostic pop
>
> I checked an example code with three compilers and noticed no standard
> related warnings. I can ask on a C/C++ mailing list if the code is
> standard compliant. It could be Coverity bug.
>
> #include <cstddef>
>
> void f(void);
>
> static_assert(f != NULL, "f");
>
> constexpr bool g()
> {
> return f != NULL;
> }
>
> extern const bool b;
>
> const bool b = g();
>
> arm-rtems6-g++ -Wall -Wextra -pedantic -std=c++11 -S -o - test.cc
> .cpu arm7tdmi
> .eabi_attribute 20, 1
> .eabi_attribute 21, 1
> .eabi_attribute 23, 3
> .eabi_attribute 24, 1
> .eabi_attribute 25, 1
> .eabi_attribute 26, 2
> .eabi_attribute 30, 6
> .eabi_attribute 34, 0
> .eabi_attribute 18, 4
> .file "test.cc"
> test.cc:5:17: warning: the address of 'void f()' will never be NULL
> [-Waddress]
> 5 | static_assert(f != NULL, "f");
> | ^
> test.cc: In function 'constexpr bool g()':
> test.cc:9:12: warning: the address of 'void f()' will never be NULL
> [-Waddress]
> 9 | return f != NULL;
> | ^
> .text
> .global b
> .section .rodata
> .type b, %object
> .size b, 1
> b:
> .byte 1
> .ident "GCC: (GNU) 10.2.1 20201203 (RTEMS 6, RSB
> ff6b2320ed34abab48751022085912217f42590d, Newlib 7fa8405)"
>
>
> g++ -Wall -Wextra -pedantic -std=c++11 -S -o - test.cc
> .file "test.cc"
> test.cc:5:17: warning: the address of ‘void f()’ will never be NULL
> [-Waddress]
> static_assert(f != NULL, "f");
> ^
> test.cc: In function ‘constexpr bool g()’:
> test.cc:9:12: warning: the address of ‘void f()’ will never be NULL
> [-Waddress]
> return f != NULL;
> ^
> .text
> .globl b
> .section .rodata
> .type b, @object
> .size b, 1
> b:
> .byte 1
> .ident "GCC: (SUSE Linux) 7.5.0"
> .section .note.GNU-stack,"", at progbits
>
>
> clang -Wall -Wextra -pedantic -std=c++11 -S -o - test.cc
> test.cc:5:15: warning: comparison of function 'f' not equal to a null
> pointer is always true [-Wtautological-pointer-compare]
> static_assert(f != NULL, "f");
> ^ ~~~~
> test.cc:5:15: note: prefix with the address-of operator to silence
> this warning
> static_assert(f != NULL, "f");
> ^
> &
> test.cc:9:10: warning: comparison of function 'f' not equal to a null
> pointer is always true [-Wtautological-pointer-compare]
> return f != NULL;
> ^ ~~~~
> test.cc:9:10: note: prefix with the address-of operator to silence
> this warning
> return f != NULL;
> ^
> &
> .text
> .file "test.cc"
> .type b, at object # @b
> .section .rodata,"a", at progbits
> .globl b
> b:
> .byte 1 # 0x1
> .size b, 1
>
>
> .ident "clang version 7.0.1 (tags/RELEASE_701/final 349238)"
> .section ".note.GNU-stack","", at progbits
> .addrsig
> .addrsig_sym b
> 2 warnings generated.
>
I checked this C code
#include <stddef.h>
void f(void);
_Static_assert(f != 0, "f");
and here we get pedantic warnings and errors:
test.c:5:18: warning: expression in static assertion is not an integer
constant expression [-Wpedantic]
5 | _Static_assert(f != 0, "f");
test.c:5:16: error: static_assert expression is not an integral constant
expression
_Static_assert(f != 0, "f");
^~~~~~
It seems we cannot use a static assertion to catch these errors.
--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.huber at embedded-brains.de
phone: +49-89-18 94 741 - 16
fax: +49-89-18 94 741 - 08
Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
More information about the devel
mailing list