C++ 17 Compiler

May I please know if a C++ 17 compiler available?
If available, what is its name or link to download the compiler please?

http://en.cppreference.com/w/cpp/compiler_support lists C++17 features and shows which versions of which compilers support them.
Last edited on
Thank you very much. I will look at the compiler. Best regards.
I have gcc.exe on my computer. May I please know how to find version of gcc.exe I have.
May I please know what is the command line to compile using C++ 17 features?
I used from DOS command gcc --version and came to know that I have 4.9.2.
Thanks
Is there a way (introductory tutorial) to download and install latest version of gcc 7 or 7.1 on Windows 10 please?
closed account (E0p9LyTq)
http://bfy.tw/Be5w
Don't bother with GCC 7.1 just yet, as far as C++17 is concerned.

It accepts a -std=c++17 option, but it still hasn't got something as fundamental as evaluation of expressions right.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
int foo( int i )
{
    
    // C++17 specifies : 
    // In every simple assignment expression E1=E2 
    // and every compound assignment expression E1@=E2, 
    // every value computation and side-effect of E2 is sequenced before
    // every value computation and side effect of E1
    // http://en.cppreference.com/w/cpp/language/eval_order

    // [x86-64 gcc 7.1 with -std=c++17 -Wall -Wextra -Werror -pedantic-errors -O3 ] 
    // error: operation on 'i' may be undefined
    i = ++i - 1 ; 

    return i ;
}

<Compilation failed>

https://godbolt.org/g/cLdwkk
It seems to work with clang 4.0.0 and -std=gnu++1z on godbolt :+)
I found this in the gcc manual for version 7.1:

gcc7_1 wrote:
-Wsequence-point

....

Examples of code with undefined behavior are a = a++;, a[n] = b[n++] and a[i++] = i;. Some more complicated cases are not diagnosed by this option, and it may give an occasional false positive result, but in general it has been found fairly effective at detecting this sort of problem in programs.

The C++17 standard will define the order of evaluation of operands in more cases: in particular it requires that the right-hand side of an assignment be evaluated before the left-hand side, so the above examples are no longer undefined. But this warning will still warn about them, to help people avoid writing code that is undefined in C and earlier revisions of C++.

....


So that seems to explain why it worked on clang.

The trouble with that is: I guess one wouldn't want to play Russian Roulette with -Wnosequence-point ; there are still some expressions that remain unspecified - http://stackoverflow.com/questions/38501587/what-are-the-evaluation-order-guarantees-introduced-by-c17#38501596
Last edited on
> I guess one wouldn't want to play Russian Roulette with -Wnosequence-point ;
> there are still some expressions that remain unspecified

And there are also expressions that engender undefined behaviour in C++17.
int i = 7 ; i = ++i + i++ ; // undefined behaviour, even in C++17

I guess the only viable option is to compile with -Wsequence-point and then examine each order of evaluation warning to figure out if it is a spurious warning.
a lot of C++17's worth is in the standard library (parallel algorithms, special functions, polymoprhic allocators, the filesystem library, etc). There are no vendors that have those as specified in the standard yet (e.g. gcc's C++17 standard library status: https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.201z clang's C++17 standard library status: http://libcxx.llvm.org/cxx1z_status.html )
Topic archived. No new replies allowed.