Reasonable minimum gcc version


(Dale Emery) #1

I received an issue report from someone who is trying to compile my modules with gcc 5.3.1, and getting a few syntax errors. The reporter himself admits that 5.3.1 is “old.”

I could likely write the code in a way that satisfies gcc 5.3.1, but (pending further analysis) I am arrogant enough to believe that my code is syntactically correct and the compiler is wrong. If I discover I’m wrong, of course I’ll fix the code.

I don’t have a good sense of what level of support to give to “old” compilers. And I don’t have a good sense of which versions are old enough that it’s reasonable not to support them.

What version of gcc is it reasonable to require? (I work entirely on macOS, and have no knowledge or opinion of gcc.)


(Andrew Belt) #2

5.3.1 is new enough to support C++11. But who knows, post the code and I’ll tell you if it’s standard.


(Dale Emery) #3

Okay, here goes.

The syntax error occurs when AdditionRangeSwitch attempts to initialize its base class Toggle<P,4> using braced initialization:

template <typename P>
class AdditionRangeSwitch : public Toggle<P, 4> {
public:
  AdditionRangeSwitch() : Toggle<P, 4>{"counter-add"} {}
};

Toggle is a template class whose constructor takes a single parameter, which has a default value:

template <typename P, int N>
class Toggle : public Control<int>,
               public rack::SVGSwitch,
               public rack::ToggleSwitch {
public:
  explicit Toggle(const std::string &name = "toggle-" + std::to_string(N)) {
      ...
  }

  ...
};

The compiler complains that braced initialization is ambiguous in that situation:

call of overloaded ‘Toggle(<brace-enclosed initializer list>)’ is ambiguous

It apparently can’t tell whether I intend to call the explicitly declared constructor or one of the compiler-generated constructors (copy or move). For the full, eye-glazing details, see the issue report: https://github.com/dhemery/DHE-Modules/issues/13#issue-396447712

I’m less sure now that the compiler is wrong, though a later version (on a different Linux) compiles the code without error.


(Skrylar) #4

GCC 7 is the oldest supported on OpenSuSE Tumbleweed, and GCC 8 is the default. I think 8 is the default on Arch as well?

I think GCC 5 is mostly used by Debian/Cent and the distros running really old “stable” stuff.