Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

single_include compilation error #75

Closed
viniciusjl opened this issue Mar 6, 2020 · 8 comments
Closed

single_include compilation error #75

viniciusjl opened this issue Mar 6, 2020 · 8 comments

Comments

@viniciusjl
Copy link

First of all, thanks for doing this library.

When compiling files in single_include_test directory, the following compilation errors occurred:

$ g++ -pthread --std=c++14 -o file1 file1.cpp
In file included from my_header.hpp:2:0,
                 from file1.cpp:1:
csv.hpp:3975:28: error: enclosing class of constexpr non-static member function ‘bool csv::CSVRow::iterator::operator==(const csv::CSVRow::iterator&) const’ is not a literal type
             constexpr bool operator==(const iterator& other) const {
                            ^~~~~~~~
csv.hpp:3945:15: note: ‘csv::CSVRow::iterator’ is not literal because:
         class iterator {
               ^~~~~~~~
csv.hpp:3945:15: note:   ‘csv::CSVRow::iterator’ has a non-trivial destructor
csv.hpp:3979:28: error: enclosing class of constexpr non-static member function ‘bool csv::CSVRow::iterator::operator!=(const csv::CSVRow::iterator&) const’ is not a literal type
             constexpr bool operator!=(const iterator& other) const { return !operator==(other); }
                            ^~~~~~~~

To fix the errors above I've just modified the following lines:

(the lines commented are the original ones)

csv.hpp

        class iterator {
   ......
            /** Two iterators are equal if they point to the same field */
//|            constexpr bool operator==(const iterator& other) const {
            inline bool operator==(const iterator& other) const {
                return this->i == other.i;
            };

//|            constexpr bool operator!=(const iterator& other) const { return !operator==(other); }
            inline bool operator!=(const iterator& other) const { return !operator==(other); }

file1.hpp

//|int foobar(int argc, char** argv) {
int main(int argc, char** argv) {
    using namespace csv;

The file2.hpp is ok.

@viniciusjl
Copy link
Author

BTW, the include/internal/csv_row.hpp file was also modified the same way as single_include_test/csv.hpp file above.

@vincentlaucsb
Copy link
Owner

What version of g++ are you using? Seems like a compiler bug since the Travis build using g++ succeeds with std=c++11.

https://stackoverflow.com/questions/36489369/constexpr-non-static-member-function-with-non-constexpr-constructor-gcc-clang-d

@viniciusjl
Copy link
Author

$ g++ --version
g++ (Debian 6.3.0-18+deb9u1) 6.3.0 20170516
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$

The bug reported in the link was fixed in g++ v5.1.0.

@viniciusjl
Copy link
Author

BTW, using std=c++11 the problem still happens.

@viniciusjl
Copy link
Author

Well, in the bug tracker header is written that the bug was fixed in g++ v5.1.0, but reading the bug tracker comments I saw that the bug was fixed in g++ v7.2.

So, it seems a compiler bug, what g++ version was used in csv tests?

@vincentlaucsb
Copy link
Owner

https://travis-ci.org/vincentlaucsb/csv-parser/jobs/646741008

I use g++ 8. I'm thinking about applying a modification similar to yours based on g++ version since it's a simple fix, but I don't want to maintain g++ 5 compatibility forever. I'll think about it.

@viniciusjl
Copy link
Author

I'm thinking to use clang v9 instead g++, but first I have to check the modification cost.

@vincentlaucsb
Copy link
Owner

Fixed by #179

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants