Questions tagged [c17]

C17 is the informal name of the current standard (ISO/IEC 9899:2018) of the C programming language. It replaces C11, but introduces no new features. Instead the focus of C17 has been to resolve defect reports (DRs).

Important Note: All C related questions, shall be tagged as , and then as a complement, each should specify the version of the standard it is using. In case of the current standard, this complement should be the tag. Please see the tag for details.

Detection

A standard macro __STDC_VERSION__ is defined with the value 201710L to indicate that C17 support is available.

More Info:

64 questions
83
votes
2 answers

What is C17 and what changes have been made to the language?

As I was checking news about GCC 8, I saw that they added support for the 2017 version of the C language (not C++17, really C17). But I can't find any information about it on Internet. Is it a new ISO version like C11, or just a codename used by the…
informaticienzero
  • 1,796
  • 1
  • 12
  • 22
31
votes
3 answers

Does the definition int a = 0, b = a++, c = a++; have defined behavior in C?

Does the definition int a = 0, b = a++, c = a++; have defined behavior in C? Or almost equivalently, does the comma in an object definition introduce a sequence point as for the comma operator in expressions? Similar questions have been asked for…
chqrlie
  • 131,814
  • 10
  • 121
  • 189
12
votes
2 answers

How does C17 want me to initialize my atomics?

The C17 standard deprecates ATOMIC_VAR_INIT from stdatomic.h, meaning it still supports it but would rather it not be used. What is the correct non-deprecated way of initializing atomics in C17? Same as non-atomic types: atomic_int foo = 42; Or…
Wingblade
  • 9,585
  • 10
  • 35
  • 48
11
votes
1 answer

Is indexing a string literal an initializer constant expression?

The following code attempts to use array indexing on a string literal in two different constant contexts: static char x = "abcx"[3]; _Static_assert ("abcx"[3] == 'x', "..."); Judging by Compiler Explorer, there's clear consensus among tool vendors…
Alex Celeste
  • 12,824
  • 10
  • 46
  • 89
11
votes
2 answers

Will i=i++ be newly well-defined in C17?

After stumbling across the question "Why are these constructs using pre and post-increment undefined behavior?" today I decided to grab the newest draft for the next C standard I could find and read more about it. Shortly after I discovered the…
asynts
  • 2,213
  • 2
  • 21
  • 35
8
votes
1 answer

Is this C program with two struct definitions, involving a flexible array member, defined?

The fact that a struct with a flexible array member is a type with which a variable can be declared and to which sizeof can be applied leads to an unusual behavior in the following program. file fam1.c: #include #include struct…
Pascal Cuoq
  • 79,187
  • 7
  • 161
  • 281
6
votes
4 answers

Which sections of the C standard prove the relation between the integer type sizes?

In the late draft of C11 [C11_N1570] and C17 [C17_N2176] I fail to find the proof of the following (which, I believe, is commonly known): sizeof(short) <= sizeof(int) <= sizeof(long) <= sizeof(long long) Can anybody refer me to the particular…
Robin Kuzmin
  • 742
  • 4
  • 12
5
votes
2 answers

clang/gcc cannot set global variables to an address constant minus another address constant

The program below compiles without errors. #include char addr_a[8]; char addr_b[8]; unsigned long my_addr = (unsigned long)addr_b - 8; // PASS // unsigned long my_addr = (unsigned long)addr_b - (unsigned…
Jorge
  • 109
  • 5
4
votes
2 answers

Can extension cancel the existing standard requirements?

Follow-up question for Why do conforming implementations behave differently w.r.t. incomplete array types with internal linkage?. Context: in both gcc and clang (conforming implementations) by default the requirement C11,6.9.2p3 [1] is cancelled,…
pmor
  • 5,392
  • 4
  • 17
  • 36
4
votes
2 answers

Why not all the standard headers are preceded with std prefix?

Why not all the standard headers are preceded with std prefix? I.e. why complex.h and not stdcomplex.h?
pmor
  • 5,392
  • 4
  • 17
  • 36
4
votes
2 answers

Does name of stdatomic.h contradict with (potential) restriction of the mapping to eight significant characters before the period?

ISO/IEC 9899:2011 (E): 6.10.2.5 The implementation may ignore distinctions of alphabetical case and restrict the mapping to eight significant characters before the period. Since stdatomic.h has 9 characters before the period, does it make a…
pmor
  • 5,392
  • 4
  • 17
  • 36
4
votes
1 answer

Is fpclassify(x) == FP_NAN functionally equivalent to isnan(x)?

Is fpclassify(x) == FP_NAN functionally equivalent to isnan(x)? The same question goes for: fpclassify(x) == FP_INFINITE vs. isinf(x) fpclassify(x) == FP_NORMAL vs. isnormal(x) fpclassify(x) == FP_SUBNORMAL vs. issubnormal(x) fpclassify(x) ==…
pmor
  • 5,392
  • 4
  • 17
  • 36
4
votes
3 answers

Contradiction in C18 standard (regarding character sets)?

We read in the C18 standard: 5.1.1.2 Translation phases The precedence among the syntax rules of translation is specified by the following phases. Physical source file multibyte characters are mapped, in an implementation-defined manner, to the…
Pep
  • 625
  • 4
  • 19
4
votes
2 answers

C11 Annex K: "objects that overlap"

There is a phrase that keeps popping up in Annex K of the C standard (bounds-checking interfaces): ....copying shall not take place between objects that overlap. Considering, for example, strcpy_s( char * restrict s1, rsize_t s1max, char const *…
DevSolar
  • 67,862
  • 21
  • 134
  • 209
4
votes
1 answer

Is there something that resembles std::lock_guard in native C?

In C++ it's recommended to use lock_guard as it ensures when the object is destroyed it unlocks the mutex. Is there a way to implement the same thing in C? Or do we have to just implement it manually: lock mutex Do something on a global…
James
  • 409
  • 2
  • 4
  • 18
1
2 3 4 5