Skip to content

Commit 5ec0e6b

Browse files
committed
suppress compiler warning on gcc 14.2
1 parent 3cc1832 commit 5ec0e6b

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

src/utki/shared_ref.hpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class shared_ref
7373
explicit shared_ref(std::shared_ptr<object_type> ptr) :
7474
p(std::move(ptr))
7575
{
76-
ASSERT(this->p)
76+
utki::assert(this->p, SL);
7777
}
7878

7979
public:
@@ -102,7 +102,7 @@ class shared_ref
102102
shared_ref(const shared_ref<other_object_type>& sr) noexcept :
103103
p(sr.to_shared_ptr())
104104
{
105-
ASSERT(this->p)
105+
utki::assert(this->p, SL);
106106
}
107107

108108
/**
@@ -156,8 +156,18 @@ class shared_ref
156156
*/
157157
constexpr object_type& get() const noexcept
158158
{
159-
ASSERT(this->p)
159+
utki::assert(this->p, SL);
160+
161+
// In GCC 14.2 with -O3 and -g3, the compiler is not able to figure out that this->p is always initialized.
162+
// So, we suppress the warning.
163+
#if CFG_COMPILER == CFG_COMPILER_GCC && CFG_COMPILER_VERSION_MAJOR == 14 && CFG_COMPILER_VERSION_MINOR == 2
164+
# pragma GCC diagnostic push
165+
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
166+
#endif
160167
return *this->p;
168+
#if CFG_COMPILER == CFG_COMPILER_GCC && CFG_COMPILER_VERSION_MAJOR == 14 && CFG_COMPILER_VERSION_MINOR == 2
169+
# pragma GCC diagnostic pop
170+
#endif
161171
}
162172

163173
/**

0 commit comments

Comments
 (0)