detection_mode mode() const noexcept { return _M_detection_mode; }
const char* comment() const noexcept { return _M_comment; }
std::source_location location() const noexcept {
- return std::source_location (_M_src_loc_ptr);
+ std::source_location __loc;
+ __loc._M_impl
+ = static_cast<const source_location::__impl*>(_M_src_loc_ptr);
+ return __loc;
}
bool is_terminating () const noexcept {
return _M_evaluation_semantic == std::contracts::evaluation_semantic::enforce
private:
const __impl* _M_impl = nullptr;
- constexpr source_location (const void *__t)
- : _M_impl (static_cast <const __impl*>(__t)) {}
-
#ifdef __glibcxx_contracts
- /* To enable use of the source __impl*. */
friend class std::contracts::contract_violation;
#endif
};
+++ /dev/null
-// { dg-options "-fcontracts" }
-// { dg-do compile { target c++26 } }
-
-// We should not get errors from including this before <contracts>:
-#include <source_location>
-#include <contracts>
--- /dev/null
+// { dg-options "-fcontracts" }
+// { dg-do compile { target c++26 } }
+
+// We should not get errors from including this before <contracts>:
+#include <source_location>
+#include <contracts>
+
+// There should be no private std::source_location ctor that participates in
+// the calls to f below.
+struct S { S(char const *); };
+void f(S);
+void f(std::source_location);
+
+void
+test01()
+{
+ f(""); // { dg-bogus "ambiguous" }
+ f({""}); // { dg-bogus "ambiguous" }
+}