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

Error: reference to 'bfs' is ambiguous #37

Closed
mshockwave opened this issue May 23, 2019 · 7 comments
Closed

Error: reference to 'bfs' is ambiguous #37

mshockwave opened this issue May 23, 2019 · 7 comments

Comments

@mshockwave
Copy link

mshockwave commented May 23, 2019

Hi,
In files tools/phasar/myphasartool.cpp and tools/phasar/phasar.cpp
there is a namespace alias: namespace bfs = boost::filesystem;, which is conflict with line 33 of file include/phasar/Utils/Logger.h. Since tools/phasar/myphasartool.cpp and tools/phasar/phasar.cpp both have statement using namespace psr;.

Simply comment out the line namespace bfs = boost::filesystem; in both tools/phasar/myphasartool.cpp and tools/phasar/phasar.cpp will solve this issue.

I'm using gcc 7.4 on Ubuntu 18.04. And i believe all the newer compilers would complain this error.

@pdschubert
Copy link
Member

Hey,
Thanks a lot for reporting. Could you please paste the exact error message and state the branch that you tried to compile?

@mshockwave
Copy link
Author

Sure, i'm building at master branch, specifically at commit f9020c7b6b0bd2cc9182473b0865f296209964ff.

Here is the error message:

../tools/phasar/myphasartool.cpp: In function 'int main(int, const char**)':
../tools/phasar/myphasartool.cpp:33:20: error: reference to 'bfs' is ambiguous
   if (argc < 2 || !bfs::exists(argv[1]) || bfs::is_directory(argv[1])) {
                    ^~~
../tools/phasar/myphasartool.cpp:25:34: note: candidates are: namespace bfs = boost::boost::filesystem;
 namespace bfs = boost::filesystem;
                                  ^
In file included from ../include/phasar/PhasarLLVM/IfdsIde/FlowEdgeFunctionCache.h:22:0,
                 from ../include/phasar/PhasarLLVM/IfdsIde/Solver/IDESolver.h:40,
                 from ../include/phasar/PhasarLLVM/IfdsIde/Solver/IFDSSolver.h:23,
                 from ../include/phasar/PhasarLLVM/IfdsIde/Solver/LLVMIFDSSolver.h:29,
                 from ../tools/phasar/myphasartool.cpp:18:
../include/phasar/Utils/Logger.h:33:34: note:                 namespace psr::bfs = boost::boost::filesystem;
 namespace bfs = boost::filesystem;
                                  ^

Here is my compiler and OS version:

$ c++ --version
c++ (Ubuntu 7.4.0-1ubuntu1~18.04) 7.4.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.

$ uname -a
Linux 59e6a48da95e 5.0.0-15-generic #16-Ubuntu SMP Mon May 6 17:41:33 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

@MMory
Copy link
Member

MMory commented May 24, 2019

Hi, which modifications did you perform in order to be able to compile with gcc? I tried reproducing your issue and had to change compile flags in CMakeLists.txt. With gcc 8 everything seems to be fine.

In general, we recommend compiling with clang. We haven't really been testing with gcc.

@mshockwave
Copy link
Author

@MMory I remove line 38 in tools/phasar/phasar.cpp and line 25 in tools/phasar/myphasartool.cpp

I really don't think it's something related to compiler option. Because as I mentioned earlier: line 33 in include/phasar/Utils/Logger.h already created a namespace alias bfs within namespace psr. And in both phasar.cpp and myphasartool.cpp we have using namespace psr; so of course we will have a conflict.

I believe that some compiler option or newer compiler will have the ability to figure out that bfs in both places are the same, but i think it make more sense to modify the source code since we really should avoid this kind of ambiguous syntax.

@MMory
Copy link
Member

MMory commented May 24, 2019

I agree that those lines are at least redundant and they break compilation for at least one major compiler, so I suggest we remove them.

My question above regarding modifications was referring to removal of -MP and -Wno-return-type-c-linkage.

@mshockwave
Copy link
Author

I didn’t do any modifications in CMakeLists to resolve any compilation error caused by compiler options . However, -Wno-return-type-c-linkage did appear as a warning on my side

@pdschubert
Copy link
Member

Sure, i'm building at master branch, specifically at commit f9020c7b6b0bd2cc9182473b0865f296209964ff.

Here is the error message:

../tools/phasar/myphasartool.cpp: In function 'int main(int, const char**)':
../tools/phasar/myphasartool.cpp:33:20: error: reference to 'bfs' is ambiguous
   if (argc < 2 || !bfs::exists(argv[1]) || bfs::is_directory(argv[1])) {
                    ^~~
../tools/phasar/myphasartool.cpp:25:34: note: candidates are: namespace bfs = boost::boost::filesystem;
 namespace bfs = boost::filesystem;
                                  ^
In file included from ../include/phasar/PhasarLLVM/IfdsIde/FlowEdgeFunctionCache.h:22:0,
                 from ../include/phasar/PhasarLLVM/IfdsIde/Solver/IDESolver.h:40,
                 from ../include/phasar/PhasarLLVM/IfdsIde/Solver/IFDSSolver.h:23,
                 from ../include/phasar/PhasarLLVM/IfdsIde/Solver/LLVMIFDSSolver.h:29,
                 from ../tools/phasar/myphasartool.cpp:18:
../include/phasar/Utils/Logger.h:33:34: note:                 namespace psr::bfs = boost::boost::filesystem;
 namespace bfs = boost::filesystem;
                                  ^

Here is my compiler and OS version:

$ c++ --version
c++ (Ubuntu 7.4.0-1ubuntu1~18.04) 7.4.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.

$ uname -a
Linux 59e6a48da95e 5.0.0-15-generic #16-Ubuntu SMP Mon May 6 17:41:33 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Thanks for the detailed error message; it will be fixed today ;-)

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

3 participants