[RTEMS Project] #3799: confdefs.h declares an array with zero elements, that's invalid C

RTEMS trac trac at rtems.org
Wed Oct 2 14:59:41 UTC 2019


#3799: confdefs.h declares an array with zero elements, that's invalid C
--------------------------------+------------------------------
  Reporter:  Jens Schweikhardt  |      Owner:  (none)
      Type:  defect             |     Status:  new
  Priority:  normal             |  Milestone:
 Component:  rtems              |    Version:
  Severity:  normal             |   Keywords:  confdefs.h array
Blocked By:                     |   Blocking:
--------------------------------+------------------------------
 I'm looking at rtems/cpukit/include/rtems/confdefs.h

 {{{
 1189    #ifdef CONFIGURE_INIT
 1190      RTEMS_DEFINE_GLOBAL_SYMBOL(
 1191        _ISR_Stack_size,
 1192        CONFIGURE_INTERRUPT_STACK_SIZE
 1193      );
 1194
 1195      char _ISR_Stack_area_begin[
 1196        _CONFIGURE_MAXIMUM_PROCESSORS * CONFIGURE_INTERRUPT_STACK_SIZE
 1197      ] RTEMS_ALIGNED( CPU_INTERRUPT_STACK_ALIGNMENT )
 1198      RTEMS_SECTION( ".rtemsstack.interrupt.begin" );
 1199
 1200      const char _ISR_Stack_area_end[ 0 ]
 1201        RTEMS_SECTION( ".rtemsstack.interrupt.end" ) = { };
 1202    #endif
 }}}

 Note line 1200: `const char _ISR_Stack_area_end[ 0 ]`
 This crashes (yes, it goes boom) one of our Static Analyzer tools
 (Mathworks Polyspace if you must know).

 According to the ISO C11 Standard,

 >**6.7.6.2 Array declarators**
 >
 >**Constraints**
 >
 >1 In addition to optional type qualifiers and the keyword `static`, the
 `[` and `]` may delimit
 >an expression or `*`. If they delimit an expression (which specifies the
 size of an array), the
 >expression shall have an integer type. **If the expression is a constant
 expression, it shall
 >have a value greater than zero.**

 Could this either be fixed to declare a one element array, or, if you must
 use 0 for some reason, be a macro that I can override for Polyspace?

--
Ticket URL: <http://devel.rtems.org/ticket/3799>
RTEMS Project <http://www.rtems.org/>
RTEMS Project


More information about the bugs mailing list