-
Notifications
You must be signed in to change notification settings - Fork 3k
Turn on C99 VLAs in IAR #1985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Turn on C99 VLAs in IAR #1985
Conversation
cc @0xc0170 My thoughts is we should select a standard to conform to. C99 seems the most reasonable for C and is defined to support VLAs (for better or for worse). |
I already assumed C99. All Nanostack relatd code compiles with C99 flags turned on. |
My concern here is that ARM compiler (--cpp) and GCC compiler (gnu++98) allows vla in cpp files while IAR strictly disallows this so there is a inconsistency that is subtle. IIRC this will also break exporting to IAR but @0xc0170 will need to confirm. |
The C++ standard does not allow VLAs, so we should make sure VLA usage in C++ errors across toolchains. The "C standard" C++ is derived from has already diverged fairly significantly. @kjbracey-arm's patch correctly impacts only C code. @mjs-arm's comments over here may be relevant: |
The code, originally showing this problem, is C code, not C++. |
Might not be true for exporters (project files sometimes behaves differently than the command line, thus should be tested). @kjbracey-arm please test the exporters, this flag should be propagated there, and should only enable VLA for c code files I hope, using --vla flag in the misc options. |
this seems to blocker issue for compile mbed-os + IPv6 with IAR |
to proceed:
or
|
IAR defaults to C99 mode, but doesn't enable VLAs by default. Enable them to make it more conformant. We don't have much if any code using actual variable-length arrays, but variably-modified types are occasionally used. The same switch controls both. (VLAs were actually already enabled in most of the project export templates, but not the build script).
Looks like VLA(+VMT) support was already enabled in most of the IAR export templates. The header file in question is not used from C++ - if it was it would indeed need extra protection. Often hard to get compilers to reject specific things without throwing a global "--pedantic" switch. They don't generally have a "deactive this extension" option. But from the docs:
Adding those to the builds is straightforward, but to actually force the extra warnings on export looks like it would involve changing about 40 template files, and I'm wary I'd miss stuff. Is it worthwhile? |
ARM and GNU compilers currently are in a mode where they will accept VLAs in C++ as an extension. IAR does not accept them in C++. Avoid potential portability surprises by making GCC warn, and deactivating the extension in ArmCC.
uvision, iar and gcc makefile should be working with these changes (c/c++ flags will get mirrored there). For the rest (coide, kds and other exporters), as they require some future development, we could create a tracking issue to propagate there the flags consolidation we did for gcc make. It shall be easier to consolidate flags then any change to do copy/paste each one flag change. Please test gcc makefile export that your codebase with vla (referenced above) works, same for uvision and IAR. If you find any problems with exporters, create an issue. Thanks for adding the warnings for C++ vla use. LGTM |
@mbed-bot: TEST HOST_OSES=ALL |
@mbed-bot: TEST HOST_OSES=ALL |
[Build 521] |
@mbed-bot: TEST HOST_OSES=windows |
[Build 522] |
…..c5ee9e4 c5ee9e4 Remove content from unit tests f7ca82a Merge branch 'release_internal' into release_external b400a6a Fix for pr ARMmbed#1984 (ARMmbed#1987) 30d25bc Fix compiler warnings (ARMmbed#1986) d46d7b3 Prioritise thread control messages (ARMmbed#1984) e59dbd8 Update domain address lifetime (ARMmbed#1985) 8a5cb75 Merge pull request ARMmbed#1980 from ARMmbed/sync_with_MbedOS bd6feab Update coding style ff14e80 (via Mbed OS) nanostack: icmpv6: fix build warning f5e3423 (via Mbed OS) Require dependencies from nanostack mbed_lib.json 3aec837 Restore ws_management_api.h to the latest version cd7ae3f (via Mbed OS) Review changes corrected 4f23008 (via Mbed OS) This is a initial version of Wi-Sun interface implementation. To get Wi-Sun mesh network working, also nanostack with Wi-Sun support is needed. ws_empty_functions.c and ws_management_api.h are temporary included here, so that wisun_tasklet will compiled without problems. They will replaced with the official versions with next nanostack release. e029444 Merge pull request ARMmbed#1981 from ARMmbed/iotthd-3111 d7e8aea Path control size from 5->7. a5fe76f randomise challenge tlv for parent request retries. (ARMmbed#1977) a1c8277 Merge pull request ARMmbed#1978 from ARMmbed/IOTTHD-3219 62f8b41 Fix compiler warnings 1ec7a84 Fix issues found by coverity 5fe7120 Merge pull request ARMmbed#1974 from ARMmbed/iotthd-3100 51358f9 Removed Unncessary debug print. 136d1b1 Merge pull request ARMmbed#1973 from ARMmbed/IOTTHD-3018 4e557ae DHCPv6 update: 85b33e1 Update BBR prefix assignment (ARMmbed#1972) 899b2c5 DHCPv6 client and server update: 9009eaf Update copyright year to test files 6a56318 Update copyright year to Nanostack files a83472e Added Wi-Sun certificate and security test interfaces 7f4ebf1 Corrected compiler warnings 52e4c3f Added supplicant PAE NVM storage 92df57b Added key data access functions to key storage 5972bc3 Merge pull request ARMmbed#1959 from ARMmbed/ws_eapol_ie_update 98af118 Merge pull request ARMmbed#1965 from ARMmbed/IOTTHD-3193 fc76d1e Merge pull request ARMmbed#1963 from ARMmbed/rename_socket_h ba3a649 Added WS flagging to EAP header parser 048f14a Rename address.h 5739b4a Fixed aro registration error 887d931 Rename socket.h to ns_socket.h 7ebaa8e Add Nanostack configuration for WS (ARMmbed#1961) ed87161 Code style fix. e20028a Fix compiler warnings (ARMmbed#1957) b86f885 EAPOL data flow IE update 65472de Fixed Function protype typo. f539287 Added support for write/READ EA-IE header IE Element's ce72b55 Merge pull request ARMmbed#1958 from ARMmbed/tls_conf_err 1e8b18c Added handling for mbed TLS configuration error bdfea40 WS: Use common channel number calc function 4802aae Merge pull request ARMmbed#1930 from ARMmbed/IOTTHD-3027 2b8c846 PAE BR address write/read interface 9777ad1 Remove yotta references (ARMmbed#1954) af8890b Merge pull request ARMmbed#1949 from ARMmbed/eapol_eap_and_tls c546d4f WS: Fixed EU domain channel numbers in neighbor class cff6f0b WS: Missing return value fix ebcdba5 Changed EAP-TLS identity to anonymous 34d2f15 Corrected defects and coding style 79c7157 WS: Default domain config update 0724863 Merge branch 'master' into IOTTHD-3027 65ccc41 WS: RF config set in own functions 76d235e MAC: Fixed virtual driver warnings 88641c1 Updates to PAEs and other security protocols f57138f Security key storage and certificate info updates b7177c5 TLS security protocol and mbed TLS security protocol library 9c9e3c9 EAP-TLS protocol implementation 9c5fc92 WS: Fixed code style acce0dd Added empty function for test 4b28192 Added support for ARO registration failure 9d251fa Added empty function fr new interface 61f520f Added api to configure network size parameters 4d26258 Flagged mbed TLS KW header and corrected bool definitions 3d903fa Corrected NIST AES KW flagging 2f4e099 Removed temporary KW functions and corrected ut and style 6481549 Added GKH MIC validation and encryption cc3ce58 Moved 4WH functions to library and added constants 650771c Added unit test to NIST AES KW library 6a82e7d added parent priority handling. (ARMmbed#1942) 7b7f1c1 Merge pull request ARMmbed#1945 from ARMmbed/fix_synch_parent_warn 38b28e2 Fix coverity error (ARMmbed#1943) c4afedc thread_mle_message_handler: fix build warning (ARMmbed#1940) a5be64a Follow Mbed OS coding style (ARMmbed#1941) 6298cef Sync mbed_lib.json with Mbed OS (ARMmbed#1935) afe3ec6 Added Wi-Sun flagging to eapol helper 28d10d6 Merge pull request ARMmbed#1901 from ARMmbed/kmp_pae_init 3f56121 Disabled EAPOL flags 97f07a9 Tuned EAPOL timers for small networks 6e063b6 added Wi-SUN neighbor table management to Wi-SUN 7f4c61d Corrected KMP api start on authenticator 91ca2e6 Corrected KMP timer active check and security protocol address get 65d983f If mbedtls NIST AES KW is not enabled defined it as null algorithm 16dbe27 Added unit test stub for PAE controller a524936 Moved EAPOL relay port and IP address configuration to bootstrap 68fa4f6 Added extra debug info flags to new security libraries c4411ea Removed extra memory frees from KMP socket and eapol if and fixed KMP comments 8088a86 Added and fixed security protocols comments cc32457 Modified PAEs to use protocol core timer function call 03469f3 Modified PAE entities to be bound to interface 369c8a0 Added 4WH integrity protection and encryption ebae1d5 Added HMAC-SHA1, IEEE 802.11 PRF and NIST AES KW libraries 2d50887 Corrected Wi-SUN security component initializations 8a8b6ef Added configuration flags for supplicant and authenticator PAEs and EAPOL relay 3868ff1 PAE and security protocols timer support c61066a Corrected GKH to set eapol-KEY message group key negotation bit correctly dfe52d9 Added 4WH,GKH and EAP-TLS module and modified kmp service 782f3fb Relay message flow optimization bbd6ee1 Integrate EAPOL new encode and decode functionality 1802ee7 EAPOL message parser and write helper function. da15653 EAPOL relay and KMP changes fad633f EAPOL relay cc97054 Unicast Shedule update a099524 EAPOL authtentication start fix 3f32a7a Fix valgrind uninitilaized data use. 6e9f6a4 Corrected memory errors and some compiler warnings c5f1af3 Initial EAPOL changes e48aa79 WS: Use Tack in Ack wait time 59a65ea Change FHSS timing defaults be06ecb FHSS WS: Fixed synch parent warning a3aa38b Thread extension commission updates (ARMmbed#1870) 3e89d0a Multicast registrations update (ARMmbed#1931) e18055a MAC: Update symbol rate when RF configuration changed 9eada28 WS: Store RF configuration 35145a3 MAC: RF configuration delivery implemented d6b2bbc Merge pull request ARMmbed#1928 from ARMmbed/IOTTHD-3028 80683e2 MAC/WS: Implemented Ack wait duration set 0e9ead2 Remove excess tracing (ARMmbed#1927) ae210cd Merge pull request ARMmbed#1923 from ARMmbed/IOTTHD-3080 17fad47 Merge pull request ARMmbed#1924 from ARMmbed/IOTTHD-1608 6fd6bd5 Update thread neighbor table initialisation (ARMmbed#1926) c09d38a Merge pull request ARMmbed#1925 from ARMmbed/fix_protocol_if_fhss 9ac5301 MAC MLME: Removed BEA TX trace which was causing stack overflow 5dee7b1 FHSS: Use debug callback in TX/RX slot switch f779fad WS/Protocol: Fixed getting interface pointer using FHSS api 4177fa4 Prevalidate CoAP msg source address 5451b1a FHSS unit tests: Updated timestamp callback a2997b1 FHSS: Removed debug trace which was causing crash 3b6a921 FHSS: Debug callback update ec1c41d FHSS: Use given TX time in synch calculation f0c0f66 MAC: Write FHSS synch info with tx time 78ea0eb FHSS: Debug callbacks added c4ef759 MAC: Write FHSS synch info before calling PHY TX function 9cca341 FHSS: Use timestamp delivered by MAC be46564 Add CoAP message validation 883eb46 Add callback for CoAP message prevalidation (ARMmbed#1918) 59bbe31 Merge pull request ARMmbed#1917 from ARMmbed/IOTTHD-3029 ac4a76e Fixed promiscuous/sniffer mode bc2fb64 FHSS WS: time convert to support negative values 7dce509 FHSS WS: Clock drift compensation implemented ac7c90a Fix Thread resolution client initialisation (ARMmbed#1915) b744186 Set the default unicast channel function as Direct Hash 612c4b5 Update DHCP to follow Wi-SUN specification eeb5168 IPv6 route metrics update (ARMmbed#1912) 1debcca Fix compilation warnings noticed in mbed-os (ARMmbed#1909) 0a18231 Change ARO routes to be direct route instead of on-link 7fb321e Merge pull request ARMmbed#1906 from ARMmbed/parent_update_fix b5afc35 Fixed missing broadcast synch information loose with default zeroes. 3dbc874 Add missing closing bracket 0d746f0 Changed Wi-SUN HW type to match specification 2804bf4 Enabled roaming and routing between multiple Wi-SUN BR git-subtree-dir: features/nanostack/sal-stack-nanostack git-subtree-split: c5ee9e4
IAR defaults to C99 mode, but doesn't enable VLAs by default. Enable them
to make it more conformant.
We don't have much if any code using actual variable-length arrays, but
variably-modified types are occasionally used. The same switch controls
both.