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

Compilation error on g++ 7.3.0 #23

Open
slonm opened this issue Mar 16, 2019 · 3 comments
Open

Compilation error on g++ 7.3.0 #23

slonm opened this issue Mar 16, 2019 · 3 comments

Comments

@slonm
Copy link

slonm commented Mar 16, 2019

sl@acer17:~/project/NamedType$
make
g++ -std=c++14 -g -O0 main.cpp -o main -Wall -Wextra -Wno-noexcept-type
main.cpp: In function ‘void changeValue(NameRef)’:
main.cpp:51:18: error: passing ‘std::remove_reference_t<std::__cxx11::basic_string<char>&> {aka const std::__cxx11::basic_string<char>}’ as ‘this’ argument discards qualifiers [-fpermissive]
     name.get() = "value2";
                  ^~~~~~~~
In file included from /usr/include/c++/7/string:52:0,
                 from catch.hpp:207,
                 from main.cpp:2:
/usr/include/c++/7/bits/basic_string.h:693:7: note:   in call to ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’
       operator=(const _CharT* __s)
       ^~~~~~~~
In file included from named_type.hpp:5:0,
                 from main.cpp:10:
underlying_functionalities.hpp: In instantiation of ‘struct fluent::MethodCallable<fluent::NamedType<____C_A_T_C_H____T_E_S_T____32()::A&, ____C_A_T_C_H____T_E_S_T____32()::StrongATag, fluent::Callable> >’:
underlying_functionalities.hpp:120:8:   required from ‘struct fluent::Callable<fluent::NamedType<____C_A_T_C_H____T_E_S_T____32()::A&, ____C_A_T_C_H____T_E_S_T____32()::StrongATag, fluent::Callable> >’
named_type_impl.hpp:21:19:   required from ‘class fluent::NamedType<____C_A_T_C_H____T_E_S_T____32()::A&, ____C_A_T_C_H____T_E_S_T____32()::StrongATag, fluent::Callable>’
main.cpp:283:5:   required from here
underlying_functionalities.hpp:115:14: error: forming pointer to reference type ‘____C_A_T_C_H____T_E_S_T____32()::A&’
     T const* operator->() const { return std::addressof(this->underlying().get()); }
              ^~~~~~~~
underlying_functionalities.hpp:116:8: error: forming pointer to reference type ‘____C_A_T_C_H____T_E_S_T____32()::A&’
     T* operator->() { return std::addressof(this->underlying().get()); }
        ^~~~~~~~
Makefile:4: recipe for target 'main' failed
make: *** [main] Error 1
sl@acer17:~/project/NamedType$

sl@acer17:~/project/NamedType$ g++ --version
g++ (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
Copyright (C) 2017 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.

@Bu11etmagnet
Copy link

clang said:

$ clang++-99 -Wall -pedantic -Wextra main.cpp 
main.cpp:51:16: error: no viable overloaded '='
    name.get() = "value2";
    ~~~~~~~~~~ ^ ~~~~~~~~
/usr/local/lib/gcc/x86_64-pc-linux-gnu/8.0.1/include/c++/bits/basic_string.h:654:7: note: candidate function not viable: 'this' argument has type
      'const std::remove_reference_t<basic_string<char> &>' (aka 'const std::__cxx11::basic_string<char>'), but method is not marked const
      operator=(const basic_string& __str)
      ^
/usr/local/lib/gcc/x86_64-pc-linux-gnu/8.0.1/include/c++/bits/basic_string.h:693:7: note: candidate function not viable: 'this' argument has type
      'const std::remove_reference_t<basic_string<char> &>' (aka 'const std::__cxx11::basic_string<char>'), but method is not marked const
      operator=(const _CharT* __s)
      ^
/usr/local/lib/gcc/x86_64-pc-linux-gnu/8.0.1/include/c++/bits/basic_string.h:704:7: note: candidate function not viable: 'this' argument has type
      'const std::remove_reference_t<basic_string<char> &>' (aka 'const std::__cxx11::basic_string<char>'), but method is not marked const
      operator=(_CharT __c)
      ^
/usr/local/lib/gcc/x86_64-pc-linux-gnu/8.0.1/include/c++/bits/basic_string.h:722:7: note: candidate function not viable: 'this' argument has type
      'const std::remove_reference_t<basic_string<char> &>' (aka 'const std::__cxx11::basic_string<char>'), but method is not marked const
      operator=(basic_string&& __str)
      ^
/usr/local/lib/gcc/x86_64-pc-linux-gnu/8.0.1/include/c++/bits/basic_string.h:776:7: note: candidate function not viable: 'this' argument has type
      'const std::remove_reference_t<basic_string<char> &>' (aka 'const std::__cxx11::basic_string<char>'), but method is not marked const
      operator=(initializer_list<_CharT> __l)
      ^
1 error generated.

@knatten
Copy link
Contributor

knatten commented Sep 27, 2019

This is fixed in #30

@jasonbeach
Copy link

In the top error (for g++) there are actually two errors. One of them was fixed in #30 but the other appears to still be there. I've tried comiling on g++ 5.5 (yikes I know) and g++ 8.1, same issue. It compiles fine on clang 3.8.

$ g++ main.cpp -o main -O3 --std=c++14
In file included from named_type.hpp:5,
                 from main.cpp:10:
underlying_functionalities.hpp: In instantiation of ‘struct fluent::MethodCallable<fluent::NamedType<____C_A_T_C_H____T_E_S_T____32()::A&, ____C_A_T_C_H____T_E_S_T____32()::StrongATag, fluent::Callable> >’:
underlying_functionalities.hpp:120:8:   required from ‘struct fluent::Callable<fluent::NamedType<____C_A_T_C_H____T_E_S_T____32()::A&, ____C_A_T_C_H____T_E_S_T____32()::StrongATag, fluent::Callable> >’
named_type_impl.hpp:21:19:   required from ‘class fluent::NamedType<____C_A_T_C_H____T_E_S_T____32()::A&, ____C_A_T_C_H____T_E_S_T____32()::StrongATag, fluent::Callable>’
main.cpp:283:5:   required from here
underlying_functionalities.hpp:115:14: error: forming pointer to reference type ‘____C_A_T_C_H____T_E_S_T____32()::A&’
     T const* operator->() const { return std::addressof(this->underlying().get()); }
              ^~~~~~~~
underlying_functionalities.hpp:116:8: error: forming pointer to reference type ‘____C_A_T_C_H____T_E_S_T____32()::A&’
     T* operator->() { return std::addressof(this->underlying().get()); }

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

4 participants