C Compile error with clang++ 3.4

I've ported Pacific Bioscience's unanimity, but the latest does not compile with clang 3.4.1 (base compiler on 10.4). It's fine with clang 4 or 5.

I'd prefer to patch the code to work with clang 3.4 rather than add an llvm dependency for 10.4-RELEASE. Any hints would be appreciated. In the meantime, I'll be trying to bring my C++ skills up-to-date (again).

Code and error messages below.

Thanks...

Code:
namespace PacBio {
namespace GenomicConsensus {

class Input
{
public:
    explicit Input(const Settings& settings) : settings_{settings} {}

    Input() = delete;
    Input(const Input&) = delete;
    Input(Input&&) = default;
    Input& operator=(const Input&) = delete;
    Input& operator=(Input&&) = default;
    ~Input() = default;

public:
    ReferenceWindow EnlargedWindow(const ReferenceWindow& window) const;
    std::vector<PacBio::BAM::BamRecord> ReadsInWindow(const ReferenceWindow& win
dow) const;
    std::string ReferenceInWindow(const ReferenceWindow& window) const;
    std::vector<ReferenceWindow> ReferenceWindows() const;

private:
    Settings settings_;
};
Code:
/usr/bin/c++   -I/usr/local/include/PacBio -Iinclude -Igenerated -I/usr/local/include -I/usr/local/include/htslib -Ithird-party/cpp-optparse -I/usr/local/include/pbbam -Ithird-party/cssw -Isrc -O2 -pipe -fstack-protector -fno-strict-aliasing -Wall -Wextra -Wno-unused-parameter -Wno-unused-variable -O2 -pipe -fstack-protector -fno-strict-aliasing   -std=c++1y -MD -MT src/CMakeFiles/arrow.dir/main/arrow.cpp.o -MF src/CMakeFiles/arrow.dir/main/arrow.cpp.o.d -o src/CMakeFiles/arrow.dir/main/arrow.cpp.o -c src/main/arrow.cpp
In file included from src/main/arrow.cpp:6:
include/pacbio/genomicconsensus/Input.h:28:58: error: no viable conversion from 'const PacBio::GenomicConsensus::Settings' to 'std::string' (aka 'basic_string<char, char_traits<char>, allocator<char> >')
    explicit Input(const Settings& settings) : settings_{settings} {}
                                                         ^~~~~~~~
/usr/include/c++/v1/string:1326:5: note: candidate constructor not viable: no known conversion from 'const PacBio::GenomicConsensus::Settings' to 'const std::__1::basic_string<char> &' for 1st argument
    basic_string(const basic_string& __str);
    ^
/usr/include/c++/v1/string:1330:5: note: candidate constructor not viable: no known conversion from 'const PacBio::GenomicConsensus::Settings' to 'std::__1::basic_string<char> &&' for 1st argument
    basic_string(basic_string&& __str)
    ^
/usr/include/c++/v1/string:1335:31: note: candidate constructor not viable: no known conversion from 'const PacBio::GenomicConsensus::Settings' to 'const value_type *' (aka 'const char *') for 1st argument
    _LIBCPP_INLINE_VISIBILITY basic_string(const value_type* __s);
                              ^
/usr/include/c++/v1/string:1356:5: note: candidate constructor not viable: no known conversion from 'const PacBio::GenomicConsensus::Settings' to 'initializer_list<value_type>' for 1st argument
    basic_string(initializer_list<value_type> __il);
    ^
In file included from src/main/arrow.cpp:6:
include/pacbio/genomicconsensus/Input.h:28:66: warning: missing field 'referenceFilename' initializer [-Wmissing-field-initializers]
    explicit Input(const Settings& settings) : settings_{settings} {}
                                                                 ^
In file included from src/main/arrow.cpp:7:
include/pacbio/genomicconsensus/Output.h:83:61: error: no viable conversion from 'const PacBio::GenomicConsensus::Settings' to 'std::string' (aka 'basic_string<char, char_traits<char>, allocator<char> >')
inline Output::Output(const Settings& settings) : settings_{settings}
                                                            ^~~~~~~~
/usr/include/c++/v1/string:1326:5: note: candidate constructor not viable: no known conversion from 'const PacBio::GenomicConsensus::Settings' to 'const std::__1::basic_string<char> &' for 1st argument
    basic_string(const basic_string& __str);
    ^
/usr/include/c++/v1/string:1330:5: note: candidate constructor not viable: no known conversion from 'const PacBio::GenomicConsensus::Settings' to 'std::__1::basic_string<char> &&' for 1st argument
    basic_string(basic_string&& __str)
    ^
/usr/include/c++/v1/string:1335:31: note: candidate constructor not viable: no known conversion from 'const PacBio::GenomicConsensus::Settings' to 'const value_type *' (aka 'const char *') for 1st argument
    _LIBCPP_INLINE_VISIBILITY basic_string(const value_type* __s);
                              ^
/usr/include/c++/v1/string:1356:5: note: candidate constructor not viable: no known conversion from 'const PacBio::GenomicConsensus::Settings' to 'initializer_list<value_type>' for 1st argument
    basic_string(initializer_list<value_type> __il);
    ^
In file included from src/main/arrow.cpp:7:
include/pacbio/genomicconsensus/Output.h:83:69: warning: missing field 'referenceFilename' initializer [-Wmissing-field-initializers]
inline Output::Output(const Settings& settings) : settings_{settings}
                                                                    ^
2 warnings and 2 errors generated.
 
Last edited by a moderator:
You didn't provide enough information. Maybe post a link to a GitHub repo? Perhaps they went ahead using newer C++ standard version than clang 3.4 supports? Why bother with FreeBSD 10.x? It will be end-of-lifed in few months.
 
Upstream project:

https://github.com/PacificBiosciences/unanimity

Work-in-progress port can be found here:

https://github.com/outpaddling/freebsd-ports-wip

I have to make a reasonable effort to support to get the port working on all currently supported releases.

Moving the initializer inside the function body silences the error and I think it's valid in this case, although I haven't maintained my C++ skills in recent years.

Clang 3.4 supposedly fully supports C++14. Is using an argument variable in an initializer a C++17 feature?

Code:
 class Input
 {
 public:
-    explicit Input(const Settings& settings) : settings_{settings} {}
+    //explicit Input(const Settings& settings) : settings_{settings} {}
+    explicit Input(const Settings& settings) { settings_ = settings; }
 
     Input() = delete;
 
Perhaps explicit Input(const Settings& settings) : settings_(settings) {} would correctly match to Settings' implicit copy-constructor.

I'm a quite bit behind the standard, since embedded systems' compilers, we're forced to use, probably will never be updated (besides some hardware vendors are already out of business).
 
Back
Top