Language request: C++14

Could CG share their views on the possibility to introduce C++14 as a supported extension of C++?
It would be a great incentive to continue learning C++ stuff but with a more (decent) recent version.

We’ll try to do a round of languages updates before the end of the year. C++ should be part of it.

4 Likes

Oh nice. Don’t forget the O3 update. Very important update.

All i want is a “C++ with O3” language. No achievements or something like that. A -Wall compilation would be appreciate too :smiley: But it’s not a big deal since we can do it locally.

3 Likes

I would prefer an own input field for specifying compiler arguments. That way all languages would profit from it, C++ isn’t the only one, that currently suffers from debug mode.

4 Likes

This is better, Maybe others want another compiler flags and not only O3

Rust suffers from debug mode even more afaik.

3 Likes

I know. But we can’t assume the cost to add a “compilation arguments field”.

The effort is bigger of course. You have to secure your server against more attack vectors such as command line injection.
Well, I can still dream of it. Asking for that feature won’t lower the chances to get it :wink:

…Exactly like you can do directly in Bash language… and I can’t see any vector attack on it.

Compiling is probably done inside a jail, with a limited user. So you can’t break your bot more than you do now :smiley:

If not, regex/replaces to reduce changes to do that.

I’m OK with pragmas, C++ is fast enough with that vs other languages.

But please, update those oldies, they have tons of bugs and missing features.
Current version of FreePascal kills a kitten everytime it compiles :imp: :knife::cat2: ,
and C++ has many compiler bugs (yes, I can’t compile some code due to gcc bugs), that are solved on more modern versions.

Hey, consider to turn on c++17 support if it will be officially supported by gcc that time.

i’m for c++1z flag too. all c++17 features are already implemented in current gcc on cg (7.2.0) but the official page says the support for it is still experimental, strange!
https://gcc.gnu.org/projects/cxx-status.html

for now im good with default O2, as O3 does more aggresive inlining, if one can turn it on with pragmas what’s the point of adding any more complexity in this area

Hello,

I have an issue with current Mean-max puzzle with C++ language.

In my code I am using the following construct:
template < typename…>
using void_t = void;

this compile perfectly with gcc 7.2 with the following flag -std=c++14 -O0 -g
But it doesn’t compile with -std=c++11.

When submitting on Codingame I encouter errors, like if it was compiled with -std=c++11 (or no flag at all)
I don’t understand why because according the codingame FAQ: g++ 7.2.0 mode C++14 should be supported.

What I am missing ?

EDIT: update code that was rendered incorrectly

It’s g++ 7.2.0 with -std=c++11

C++14 is not supported on CodinGame at the moment.

Actually, we updated the languages few weeks ago. Now, we support c++ 14. https://www.codingame.com/faq
(we use the -std=gnu++14 -Werror=return-type -g -pthread -lm -lpthread -ldl -lcrypt compilation flag)

So it should work. Maybe there is a problem in the code?

The code compile fine with -std=c++14. So it seems rather that -std=gnu++14 and -std=c++14 are two different things from gcc doc. I don’t understand yet what are the key differences => I 'll try to compile with the flag -std=gnu++14 to confirm that it is the issue I’am encoutering.

But It if the case for me it means that -std=gnu++14 is not C++14 compliant, because my code compile fine with clang as well.

I have done the test and can confirm that my code compile fine with:

g+±7 -std=c++14 -O0 -g code_generated.cc -o a.gcc

But gives error with:

g+±7 -std=gnu++14 -O0 -g code_generated.cc -o a.gcc

and produces the following error (so my initial post):
_array.hh:12:59: error: reference to ‘void_t’ is ambiguous
_template <typename, template class, typename = void_t<>>

Digging further I found that the error is misleading (there is a lot of stackoverlflow issue on this one), but I do not yet understand the core issue.

This kind of code is used in conjunction with SFINAE to do template meta programming. It’s quite painfull to analyse these errors when the compiler doesn’t behave as expected.

As I mentioned earlier, compiling the same code with clang (an alternative c++ compiler) works fine.

I feel sorry to ask that, but it seems that -std=c++14 is more close to the C++14 standard than the -std=gnu++14 options (for whatever it means). Wouldn’t it be more sensible to use the former rather than the latter ? (And putting aside it would solve my issue :slight_smile: )

I find more details supporting that in gcc doc:

Another revised ISO C++ standard was published in 2014 … and is referred to as C++14; … To select this standard in GCC, use the option -std=c++14.

Whereas

By default, GCC also provides some additional extensions to the C++ language that on rare occasions conflict with the C++ standard. … Use of the -std options listed above disables these extensions where they they conflict with the C++ standard version selected. … or -std=gnu++14 (for C++14 with GNU extensions)…

Nice detective work :slight_smile:

Does anyone know if the tool at https://tech.io/snippet?l=cpp is supposed to use the same compiler options as codingame? It doesn’t seem to link pthread when I try to use std::thread.

With a small example like:

#include <thread>

void task() {}

int main()
{
    std::thread t1(task);
    t1.join();
}

The linker on tech dot io complains with:

/usr/bin/ld: /tmp/ccSI5o9B.o: in function `std::thread::thread<void (&)(), , void>(void (&)())':
main.cc:(.text._ZNSt6threadC2IRFvvEJEvEEOT_DpOT0_[_ZNSt6threadC5IRFvvEJEvEEOT_DpOT0_]+0x21): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status

Like @_CG_Nick mentioned, I checked out the FAQ to find that codingame uses ‑lm, ‑lpthread, ‑ldl, ‑lcrypt for libraries, but it seems tech dot io doesn’t? (I also attempted to use crypt(), but the linker couldn’t find that either.)

(please excuse my links to tech dot io; It seems I am limited to the number of links I can post as a new user)

Tech.io uses docker but CodinGame doesn’t. Here’s the list of the docker images we use in Tech.io:
https://tech.io/playgrounds/408/tech-io-documentation/code-snippets