#include <algorithm> void f() { std::sort(1); } The diagnostics caused by misuse of the standard library are ridiculous: t.cc: In function 'void f()': t.cc:2:23: error: no matching function for call to 'sort(int)' t.cc:2:23: note: candidates are: In file included from /home/redi/gcc/4.x/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/../../../../include/c++/4.8.0/algorithm:63:0, from t.cc:1: /home/redi/gcc/4.x/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/../../../../include/c++/4.8.0/bits/stl_algo.h:5420:5: note: template<class _RAIter> void std::sort(_RAIter, _RAIter) /home/redi/gcc/4.x/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/../../../../include/c++/4.8.0/bits/stl_algo.h:5420:5: note: template argument deduction/substitution failed: t.cc:2:23: note: candidate expects 2 arguments, 1 provided In file included from /home/redi/gcc/4.x/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/../../../../include/c++/4.8.0/algorithm:63:0, from t.cc:1: /home/redi/gcc/4.x/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/../../../../include/c++/4.8.0/bits/stl_algo.h:5456:5: note: template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare) /home/redi/gcc/4.x/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/../../../../include/c++/4.8.0/bits/stl_algo.h:5456:5: note: template argument deduction/substitution failed: t.cc:2:23: note: candidate expects 3 arguments, 1 provided Users don't care that the include path is $PREFIX/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/../../../../include/c++/4.8.0 The paths should be canonicalized using realpath(3) to simply /home/redi/gcc/4.x/include/c++/4.8.0/algorithm and /home/redi/gcc/4.x/include/c++/4.8.0/bits/stl_algo.h This probably isn't a good idea for user headers, as the include path they use with -I should be preserved so they recognise it, but for GCC's own C++ headers (and possibly all system headers?) it would be a huge improvement.
The canonicalized version of that error is a lot more readable t.cc: In function 'void f()': t.cc:2:23: error: no matching function for call to 'sort(int)' t.cc:2:23: note: candidates are: In file included from /home/redi/gcc/4.x/include/c++/4.8.0/algorithm:63:0, from t.cc:1: /home/redi/gcc/4.x/include/c++/4.8.0/bits/stl_algo.h:5420:5: note: template<class _RAIter> void std::sort(_RAIter, _RAIter) /home/redi/gcc/4.x/include/c++/4.8.0/bits/stl_algo.h:5420:5: note: template argument deduction/substitution failed: t.cc:2:23: note: candidate expects 2 arguments, 1 provided In file included from /home/redi/gcc/4.x/include/c++/4.8.0/algorithm:63:0, from t.cc:1: /home/redi/gcc/4.x/include/c++/4.8.0/bits/stl_algo.h:5456:5: note: template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare) /home/redi/gcc/4.x/include/c++/4.8.0/bits/stl_algo.h:5456:5: note: template argument deduction/substitution failed: t.cc:2:23: note: candidate expects 3 arguments, 1 provided
(In reply to comment #0) > This probably isn't a good idea for user headers, as the include path they use > with -I should be preserved so they recognise it, but for GCC's own C++ headers > (and possibly all system headers?) it would be a huge improvement. System headers are easy to detect, but what is "GCC's own C++ headers"? How can one detect those?
I don't know where they're defined but they're built in and g++ -v shows them #include "..." search starts here: #include <...> search starts here: /home/redi/gcc/4.x/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/../../../../include/c++/4.8.0 /home/redi/gcc/4.x/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/../../../../include/c++/4.8.0/x86_64-unknown-linux-gnu /home/redi/gcc/4.x/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/../../../../include/c++/4.8.0/backward /home/redi/gcc/4.x/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/include /usr/local/include /home/redi/gcc/4.x/include /home/redi/gcc/4.x/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/include-fixed /usr/include End of search list. The C++ headers are the only ones that need canonicalizing.
Created attachment 27160 [details] patch This patch implements the shortening in line-map.c. It seems more general fix than touching the default include paths. If it looks ok to you, I will submit it properly.
That was fast :) I've only tested it lightly but it looks great, thank you very much.
Author: manu Revision: 186991 Modified property: svn:log Modified: svn:log at Mon Apr 30 17:00:59 2012 ------------------------------------------------------------------------------ --- svn:log (original) +++ svn:log Mon Apr 30 17:00:59 2012 @@ -1,6 +1,6 @@ 2012-04-30 Manuel López-Ibáñez <manu@gcc.gnu.org> Dodji Seketeli <dodji@seketeli.org> - PR 5297 + PR c++/52974 * libcpp/files.c (maybe_shorter_path): New. (find_file_in_dir): Use it.
Nice, thanks very much!
(In reply to comment #7) > Nice, thanks very much! Does it also help with the debug info? I haven't tested that. Also, I don't think it changes the output of g++ -v.
(In reply to comment #8) > Does it also help with the debug info? I haven't tested that. It does, great! > Also, I don't think it changes the output of g++ -v. It doesn't, I don't care :) Thanks again.