When including algorithm
and syscall.h
from a c++ program, ambiguous function errors are raised.
I would like to make progress adding serenity support to a a system call fuzzer named syzkaller (#1025). I have a POC, but it requires a few hacks that aren't upstreamable. This is one of them.
dummy.cpp:
#include <algorithm>
#include <syscall.h>
int main(int argc, char const *argv[])
{
if (std::max(0, 1)) {
syscall0((uintptr_t)NULL);
}
}
$ ~/repos/upstream/serenity/Toolchain/Local/i686/bin/i686-pc-serenity-gcc -lsystem -std=c++20 -o ./dummy dummy.cpp
In file included from /Users/space/repos/upstream/serenity/Build/i686/Root/usr/include/AK/Types.h:11,
from /Users/space/repos/upstream/serenity/Build/i686/Root/usr/include/AK/Forward.h:9,
from /Users/space/repos/upstream/serenity/Build/i686/Root/usr/include/AK/Concepts.h:9,
from /Users/space/repos/upstream/serenity/Build/i686/Root/usr/include/AK/Checked.h:31,
from /Users/space/repos/upstream/serenity/Build/i686/Root/usr/include/AK/StringView.h:10,
from /Users/space/repos/upstream/serenity/Build/i686/Root/usr/include/Kernel/API/Syscall.h:9,
from /Users/space/repos/upstream/serenity/Build/i686/Root/usr/include/syscall.h:9,
from dummy.cpp:2:
/Users/space/repos/upstream/serenity/Build/i686/Root/usr/include/AK/StdLibExtras.h: In instantiation of 'constexpr T AK::exchange(T&, U&&) [with T = unsigned int; U = int]':
/Users/space/repos/upstream/serenity/Build/i686/Root/usr/include/AK/Checked.h:133:27: required from 'constexpr AK::Checked<T>::Checked(AK::Checked<T>&&) [with T = unsigned int]'
/Users/space/repos/upstream/serenity/Build/i686/Root/usr/include/AK/Checked.h:342:12: required from 'constexpr AK::Checked<T> AK::operator*(const AK::Checked<T>&, const AK::Checked<T>&) [with T = unsigned int]'
/Users/space/repos/upstream/serenity/Build/i686/Root/usr/include/AK/kmalloc.h:44:21: required from here
/Users/space/repos/upstream/serenity/Build/i686/Root/usr/include/AK/StdLibExtras.h:130:22: error: call of overloaded 'forward<int>(int&)' is ambiguous
130 | slot = forward<U>(value);
| ~~~~~~~~~~^~~~~~~
/Users/space/repos/upstream/serenity/Build/i686/Root/usr/include/AK/StdLibExtras.h:35:15: note: candidate: 'constexpr T&& std::forward(AK::Detail::RemoveReference<T>&) [with T = int; AK::Detail::RemoveReference<T> = int]'
35 | constexpr T&& forward(AK::Detail::RemoveReference<T>& param)
| ^~~~~~~
In file included from /Users/space/repos/upstream/serenity/Toolchain/Local/i686/i686-pc-serenity/include/c++/11.2.0/bits/stl_pair.h:59,
from /Users/space/repos/upstream/serenity/Toolchain/Local/i686/i686-pc-serenity/include/c++/11.2.0/utility:70,
from /Users/space/repos/upstream/serenity/Toolchain/Local/i686/i686-pc-serenity/include/c++/11.2.0/algorithm:60,
from dummy.cpp:1:
/Users/space/repos/upstream/serenity/Toolchain/Local/i686/i686-pc-serenity/include/c++/11.2.0/bits/move.h:77:5: note: candidate: 'constexpr _Tp&& std::forward(typename std::remove_reference<_Tp>::type&) [with _Tp = int; typename std::remove_reference<_Tp>::type = int]'
77 | forward(typename std::remove_reference<_Tp>::type& __t) noexcept
| ^~~~~~~
In file included from /Users/space/repos/upstream/serenity/Build/i686/Root/usr/include/AK/Types.h:11,
from /Users/space/repos/upstream/serenity/Build/i686/Root/usr/include/AK/Forward.h:9,
from /Users/space/repos/upstream/serenity/Build/i686/Root/usr/include/AK/Concepts.h:9,
from /Users/space/repos/upstream/serenity/Build/i686/Root/usr/include/AK/Checked.h:31,
from /Users/space/repos/upstream/serenity/Build/i686/Root/usr/include/AK/StringView.h:10,
from /Users/space/repos/upstream/serenity/Build/i686/Root/usr/include/Kernel/API/Syscall.h:9,
from /Users/space/repos/upstream/serenity/Build/i686/Root/usr/include/syscall.h:9,
from dummy.cpp:2:
/Users/space/repos/upstream/serenity/Build/i686/Root/usr/include/AK/StdLibExtras.h: In instantiation of 'constexpr T AK::exchange(T&, U&&) [with T = bool; U = bool]':
/Users/space/repos/upstream/serenity/Build/i686/Root/usr/include/AK/Checked.h:134:30: required from 'constexpr AK::Checked<T>::Checked(AK::Checked<T>&&) [with T = unsigned int]'
/Users/space/repos/upstream/serenity/Build/i686/Root/usr/include/AK/Checked.h:342:12: required from 'constexpr AK::Checked<T> AK::operator*(const AK::Checked<T>&, const AK::Checked<T>&) [with T = unsigned int]'
/Users/space/repos/upstream/serenity/Build/i686/Root/usr/include/AK/kmalloc.h:44:21: required from here
/Users/space/repos/upstream/serenity/Build/i686/Root/usr/include/AK/StdLibExtras.h:130:22: error: call of overloaded 'forward<bool>(bool&)' is ambiguous
130 | slot = forward<U>(value);
| ~~~~~~~~~~^~~~~~~
/Users/space/repos/upstream/serenity/Build/i686/Root/usr/include/AK/StdLibExtras.h:35:15: note: candidate: 'constexpr T&& std::forward(AK::Detail::RemoveReference<T>&) [with T = bool; AK::Detail::RemoveReference<T> = bool]'
35 | constexpr T&& forward(AK::Detail::RemoveReference<T>& param)
| ^~~~~~~
In file included from /Users/space/repos/upstream/serenity/Toolchain/Local/i686/i686-pc-serenity/include/c++/11.2.0/bits/stl_pair.h:59,
from /Users/space/repos/upstream/serenity/Toolchain/Local/i686/i686-pc-serenity/include/c++/11.2.0/utility:70,
from /Users/space/repos/upstream/serenity/Toolchain/Local/i686/i686-pc-serenity/include/c++/11.2.0/algorithm:60,
from dummy.cpp:1:
/Users/space/repos/upstream/serenity/Toolchain/Local/i686/i686-pc-serenity/include/c++/11.2.0/bits/move.h:77:5: note: candidate: 'constexpr _Tp&& std::forward(typename std::remove_reference<_Tp>::type&) [with _Tp = bool; typename std::remove_reference<_Tp>::type = bool]'
77 | forward(typename std::remove_reference<_Tp>::type& __t) noexcept
| ^~~~~~~
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too