You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I expect original code to work because normally inside a class all variables are considered (e.g return inner.result(); is fine), but maybe I am not correct and there is wording that prohibits this code.
Note that gcc does compile this code (which I understand doesn't mean the code is correct)
Extended Description
If I use field (or this->field) inside the requires requires, clang supposes it not existent.
Code:
struct S {
double result() {
return 0;
}
};
template
class Outer {
public:
double result() requires requires {this->inner.result();} {
return inner.result();
}
Inner inner;
};
double foo() {
Outer
c;return c.result();
}
Compiler explorer link: https://godbolt.org/z/zdcTjYoE8
If I change this to
class Outer {
public:
double result() requires requires {this->inner.result();} {
return inner.result();
}
Inner inner;
};
, then it does work.
I expect original code to work because normally inside a class all variables are considered (e.g return inner.result(); is fine), but maybe I am not correct and there is wording that prohibits this code.
Note that gcc does compile this code (which I understand doesn't mean the code is correct)
options I've used: -std=c++20
clang++ -v gives me
#1 with x86-64 clang (trunk)
clang version 13.0.0 (https://github.com/llvm/llvm-project.git 0f8854f)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-trunk/bin
Found candidate GCC installation: /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/12.0.0
Selected GCC installation: /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/12.0.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@MX32
Selected multilib: .;@m64
(in-process)
"/opt/compiler-explorer/clang-trunk-20210510/bin/clang-13" -cc1 -triple x86_64-unknown-linux-gnu -S -disable-free -disable-llvm-verifier -discard-value-names -main-file-name example.cpp -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/app -resource-dir /opt/compiler-explorer/clang-trunk-20210510/lib/clang/13.0.0 -isystem /opt/compiler-explorer/libs/outcome/single-header -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/12.0.0/../../../../include/c++/12.0.0 -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/12.0.0/../../../../include/c++/12.0.0/x86_64-linux-gnu -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/12.0.0/../../../../include/c++/12.0.0/backward -internal-isystem /opt/compiler-explorer/clang-trunk-20210510/lib/clang/13.0.0/include -internal-isystem /usr/local/include -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/12.0.0/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++20 -fdeprecated-macro -fdebug-compilation-dir=/app -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fcxx-exceptions -fexceptions -fcolor-diagnostics -mllvm --x86-asm-syntax=intel -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /app/output.s -x c++
clang -cc1 version 13.0.0 based upon LLVM 13.0.0git default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/12.0.0/../../../../x86_64-linux-gnu/include"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/opt/compiler-explorer/libs/outcome/single-header
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/12.0.0/../../../../include/c++/12.0.0
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/12.0.0/../../../../include/c++/12.0.0/x86_64-linux-gnu
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/12.0.0/../../../../include/c++/12.0.0/backward
/opt/compiler-explorer/clang-trunk-20210510/lib/clang/13.0.0/include
/usr/local/include
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
The text was updated successfully, but these errors were encountered: