Discussion:
'DWIM' error reporting
(too old to reply)
Rainer Weikusat
2019-06-17 18:30:01 UTC
Permalink
Much improved compiler diagnostic due to souperior C++-technology!

web_redirect.c:61:25: error: use of undeclared identifier 'SOl_SOCKET'; did you mean 'SOCK_PACKET'?
rc = setsockopt(sk, SOl_SOCKET, SO_REUSEADDR, &rc, sizeof(rc));
James K. Lowden
2019-06-17 22:18:00 UTC
Permalink
On Mon, 17 Jun 2019 19:30:01 +0100
Post by Rainer Weikusat
did you mean 'SOCK_PACKET'
Well, obviously you wanted SOCK_PUPPET, which is just as good a choice
for socket level.
Post by Rainer Weikusat
souperior C++-technology
One can imagine a system in which the documentation is machine
readable, and the compiler could enumerate/describe the domain. That
might lead to more helpful messages. But here it looks like the
compiler is doing a string search on its symbol list or the
header file or something. Hard to believe that ever turns out well.

--jkl
Rainer Weikusat
2019-06-19 16:06:20 UTC
Permalink
Post by James K. Lowden
Post by Rainer Weikusat
did you mean 'SOCK_PACKET'
Well, obviously you wanted SOCK_PUPPET, which is just as good a choice
for socket level.
Post by Rainer Weikusat
souperior C++-technology
One can imagine a system in which the documentation is machine
readable, and the compiler could enumerate/describe the domain. That
might lead to more helpful messages. But here it looks like the
compiler is doing a string search on its symbol list or the
header file or something. Hard to believe that ever turns out well.
In this case (SOL_SOCKET mistyped as SOl_SOCKET), it's doing some fairly
sophisticated autocorrection by suggesting a constant with a Levenshtein
distance of 4 because it's apparently caseblind in this respect: It
doesn't seem to consider case changes of existing characters.
William Ahern
2019-06-20 03:33:12 UTC
Permalink
Post by Rainer Weikusat
Post by James K. Lowden
Post by Rainer Weikusat
did you mean 'SOCK_PACKET'
Well, obviously you wanted SOCK_PUPPET, which is just as good a choice
for socket level.
Post by Rainer Weikusat
souperior C++-technology
One can imagine a system in which the documentation is machine
readable, and the compiler could enumerate/describe the domain. That
might lead to more helpful messages. But here it looks like the
compiler is doing a string search on its symbol list or the
header file or something. Hard to believe that ever turns out well.
In this case (SOL_SOCKET mistyped as SOl_SOCKET), it's doing some fairly
sophisticated autocorrection by suggesting a constant with a Levenshtein
distance of 4 because it's apparently caseblind in this respect: It
doesn't seem to consider case changes of existing characters.
LLVM implements the levenshtein distance algorithm in
include/llvm/ADT/edit_distance.h, but AFAICT it's only used once in clang,
in a conditional block in lib/Sema/SemaLookup.cpp.[1][2] I don't have the
stamina to reverse engineer that code, but it certainly looks like another
great example of clang showcasing the power of C++.

[1] https://github.com/llvm-mirror/llvm/blob/6b547686/include/llvm/ADT/edit_distance.h#L42
[2] https://github.com/llvm-mirror/clang/blob/122b86d0/lib/Sema/SemaLookup.cpp#L4463
Loading...