bugAVR C Runtime Library - Bugs: bug #41689, add static_assert to assert.h


bug #41689: add static_assert to assert.h

Submitted by:  azudem <azudem>
Submitted on:  Tue 25 Feb 2014 03:52:43 PM UTC  
Category: Feature RequestSeverity: 3 - Normal
Priority: 5 - NormalItem Group: None
Status: FixedPercent Complete: 0%
Assigned to: Pitchumani <pitchumani>Open/Closed: Closed
Release: AnyFixed Release: None

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Wed 19 Oct 2016 10:38:18 AM UTC, comment #3:


This patch has been applied and committed.

Thank you for the contribution.

Pitchumani <pitchumani>
Project MemberIn charge of this item.
Fri 14 Oct 2016 01:35:07 PM UTC, comment #2:

I also recently discovered this problem (post on the mailing list). Please fix it as the solution is already provided in the comments. Thanks.

Nico <nicohood>
Wed 11 Mar 2015 04:22:58 PM UTC, comment #1:

_Static_assert may be ugly, but it's what ISO C mandates:


static_assert is syntactic sugar imported by <assert.h>.

With gcc, here is a bit of confusion on which is defined when. gcc 4.6 supports _Static_assert, but assert.h has static_assert only when std==c11. In gcc 4.7, static_assert is defined by assert.h even if std!==c11 (apparently).

I use the following chunk of code to get as much as is available:

#if (_STDC_VERSION_ >= 201112L)
#include <assert.h>
#elif (_GNUC_ > 4 || (_GNUC_ == 4 && _GNUC_MINOR_ >= 6))
#define static_assert(condition, message) _Static_assert(condition, message)
#define static_assert(condition, message)

Tue 25 Feb 2014 03:52:43 PM UTC, original submission:


#if defined __USE_ISOC11 && !defined __cplusplus
# undef static_assert
# define static_assert _Static_assert

to <assert.h>. Static assertions supported by GCC > 4.6 and very useful (especially for MCU coding). Default name '_Static_assert' is ugly.

azudem <azudem>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):

Attached Files
file #33874:  0001-easy-C11-conformance.patch added by None (1KiB - text/x-patch - Complete patch)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by pitchumani (Updated the item)
  • -unavailable- added by nicohood (Posted a comment)
  • -unavailable- added by azudem (Submitted the item)

    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 19 Oct 2016 10:38:18 AM UTCpitchumaniStatusConfirmed=>Fixed
    Wed 19 Oct 2016 10:29:25 AM UTCpitchumaniStatusNone=>Confirmed
      Assigned toNone=>pitchumani
      Summarystatic_assert=>add static_assert to assert.h
    Sat 02 May 2015 05:54:13 AM UTCNoneAttached File-=>Added 0001-easy-C11-conformance.patch, #33874

    Back to the top

    Powered by Savane 3.1-cleanup1