Skip to content

Instantly share code, notes, and snippets.

@ssnover
Created March 17, 2018 19:14
Show Gist options
  • Save ssnover/7cf939d0ba56ea7d871994494d1139ea to your computer and use it in GitHub Desktop.
Save ssnover/7cf939d0ba56ea7d871994494d1139ea to your computer and use it in GitHub Desktop.
A short example of showing volatile makes my_struct_t a non-literal type.
// Put this gist in Matt Godbolt's Compiler Explorer
// Compiler: ARM GCC 6.3
// Options: -std=c++14
#include <cstdint>
#include <type_traits>
typedef struct
{
volatile uint32_t variable1; // Remove volatile, and the condition passes
uint32_t variable2;
} my_struct_t;
int main()
{
static_assert(std::is_literal_type<my_struct_t>::value, "Not a literal type");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment