Files
gentoo/dev-cpp/glibmm/files/glibmm-2.66.8-const-whoops.patch
Kostadin Shishmanov ce7eabd031 dev-cpp/glibmm: backport const attribute patch to 2.66.8
Backport the G_GNUC_CONST patch fixing miscompilations with GCC 16 and
newer.

The test suite passes without the additionally edited
glib/src/bytearray.hg, but I thought I should include it just in case.

Bug: https://bugs.gentoo.org/970774
Signed-off-by: Kostadin Shishmanov <kostadinshishmanov@protonmail.com>
Part-of: https://codeberg.org/gentoo/gentoo/pulls/1969
Signed-off-by: Sam James <sam@gentoo.org>
2026-09-29 10:17:19 +01:00

450 lines
14 KiB
Diff

https://gitlab.gnome.org/GNOME/glibmm/-/merge_requests/77
From fa0d3e3f1159f509ab3181c4a9880431eeb6539c Mon Sep 17 00:00:00 2001
From: Sam James <sam@gentoo.org>
Date: Mon, 22 Jun 2026 00:23:05 +0100
Subject: [PATCH 1/2] tools: drop G_GNUC_CONST for get_type with pointer
argument
GCC's documentation for the `const` attribute [0] says:
> Note that a function that has pointer arguments and examines the data pointed
> to must not be declared const if the pointed-to data might change between
> successive invocations of the function.
Note that "might change" here is quite aggressive: it includes "if the
pointer escapes at all", e.g. if it's some malloc'd memory that gets reused
internally later too without something resetting its lifetime.
The `pure` attribute would be appropriate here *if* there's no state
changes even on the first run.
[0] https://gcc.gnu.org/onlinedocs/gcc/Common-Attributes.html#index-const
Bug: https://gitlab.gnome.org/GNOME/glib/-/work_items/3984
Signed-off-by: Sam James <sam@gentoo.org>
---
tools/m4/class_gobject.m4 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/m4/class_gobject.m4 b/tools/m4/class_gobject.m4
index 8635946..62b638b 100644
--- a/tools/m4/class_gobject.m4
+++ b/tools/m4/class_gobject.m4
@@ -302,7 +302,7 @@ _IMPORT(SECTION_DTOR_DOCUMENTATION)
#ifndef DOXYGEN_SHOULD_SKIP_THIS
ifdef(`__BOOL_DYNAMIC_GTYPE_REGISTRATION__',`
- static GType get_type(GTypeModule* module) G_GNUC_CONST;
+ static GType get_type(GTypeModule* module);
',`')
static GType get_base_type() G_GNUC_CONST;
--
2.55.0
From 287cbcf768644c49196efcb42bfca2560721331d Mon Sep 17 00:00:00 2001
From: Sam James <sam@gentoo.org>
Date: Mon, 22 Jun 2026 00:46:36 +0100
Subject: [PATCH 2/2] Drop G_GNUC_CONST as in glib
This mirrors 016829559e75a1be24d637cad958a2cb00c6791d in glib, where
the attributes were dropped because their use was invalid.
This fixes glibmm being miscompiled by trunk GCC.
Bug: https://gitlab.gnome.org/GNOME/glib/-/work_items/3984
Signed-off-by: Sam James <sam@gentoo.org>
---
glib/glibmm/interface.h | 4 ++--
glib/glibmm/object.h | 4 ++--
glib/glibmm/value.h | 12 ++++++------
glib/glibmm/value_custom.h | 4 ++--
glib/src/bytearray.hg | 2 +-
glib/src/value_basictypes.h.m4 | 2 +-
glib/src/variant.hg | 26 +++++++++++++-------------
glib/src/variant_basictypes.h.m4 | 2 +-
tools/m4/class_boxedtype.m4 | 2 +-
tools/m4/class_boxedtype_static.m4 | 2 +-
tools/m4/class_gobject.m4 | 4 ++--
tools/m4/class_interface.m4 | 4 ++--
tools/m4/class_opaque_refcounted.m4 | 2 +-
tools/m4/enum.m4 | 2 +-
tools/m4/gerror.m4 | 2 +-
15 files changed, 37 insertions(+), 37 deletions(-)
diff --git a/glib/glibmm/interface.h b/glib/glibmm/interface.h
index e4f04d4..f95e991 100644
--- a/glib/glibmm/interface.h
+++ b/glib/glibmm/interface.h
@@ -70,8 +70,8 @@ public:
// static Glib::Interface* wrap_new(GTypeInterface*);
#ifndef DOXYGEN_SHOULD_SKIP_THIS
- static GType get_type() G_GNUC_CONST;
- static GType get_base_type() G_GNUC_CONST;
+ static GType get_type();
+ static GType get_base_type();
#endif
inline GObject* gobj() { return gobject_; }
diff --git a/glib/glibmm/object.h b/glib/glibmm/object.h
index 824c6b7..3f13d30 100644
--- a/glib/glibmm/object.h
+++ b/glib/glibmm/object.h
@@ -119,8 +119,8 @@ public:
// static RefPtr<Object> create(); //You must reimplement this in each derived class.
#ifndef DOXYGEN_SHOULD_SKIP_THIS
- static GType get_type() G_GNUC_CONST;
- static GType get_base_type() G_GNUC_CONST;
+ static GType get_type();
+ static GType get_base_type();
#endif
// GObject* gobj_copy(); //Give a ref-ed copy to someone. Use for direct struct access.
diff --git a/glib/glibmm/value.h b/glib/glibmm/value.h
index f236471..3a1ff92 100644
--- a/glib/glibmm/value.h
+++ b/glib/glibmm/value.h
@@ -100,7 +100,7 @@ protected:
class GLIBMM_API ValueBase_Boxed : public ValueBase
{
public:
- static GType value_type() G_GNUC_CONST;
+ static GType value_type();
#ifndef DOXYGEN_SHOULD_SKIP_THIS
GParamSpec* create_param_spec(const Glib::ustring& name) const;
@@ -119,7 +119,7 @@ protected:
class GLIBMM_API ValueBase_Object : public ValueBase
{
public:
- static GType value_type() G_GNUC_CONST;
+ static GType value_type();
#ifndef DOXYGEN_SHOULD_SKIP_THIS
GParamSpec* create_param_spec(const Glib::ustring& name) const;
@@ -141,7 +141,7 @@ class GLIBMM_API ValueBase_Enum : public ValueBase
{
public:
using CType = gint;
- static GType value_type() G_GNUC_CONST;
+ static GType value_type();
#ifndef DOXYGEN_SHOULD_SKIP_THIS
GParamSpec* create_param_spec(const Glib::ustring& name) const;
@@ -162,7 +162,7 @@ class GLIBMM_API ValueBase_Flags : public ValueBase
{
public:
using CType = guint;
- static GType value_type() G_GNUC_CONST;
+ static GType value_type();
#ifndef DOXYGEN_SHOULD_SKIP_THIS
GParamSpec* create_param_spec(const Glib::ustring& name) const;
@@ -183,7 +183,7 @@ class GLIBMM_API ValueBase_String : public ValueBase
{
public:
using CType = const gchar*;
- static GType value_type() G_GNUC_CONST;
+ static GType value_type();
#ifndef DOXYGEN_SHOULD_SKIP_THIS
GParamSpec* create_param_spec(const Glib::ustring& name) const;
@@ -203,7 +203,7 @@ protected:
class GLIBMM_API ValueBase_Variant : public ValueBase
{
public:
- static GType value_type() G_GNUC_CONST;
+ static GType value_type();
#ifndef DOXYGEN_SHOULD_SKIP_THIS
GParamSpec* create_param_spec(const Glib::ustring& name, const Glib::ustring& nick,
diff --git a/glib/glibmm/value_custom.h b/glib/glibmm/value_custom.h
index 53da3db..46cfc61 100644
--- a/glib/glibmm/value_custom.h
+++ b/glib/glibmm/value_custom.h
@@ -66,7 +66,7 @@ public:
using CppType = PtrT;
using CType = void*;
- static inline GType value_type() G_GNUC_CONST;
+ static inline GType value_type();
inline void set(CppType data);
inline CppType get() const;
@@ -105,7 +105,7 @@ public:
using CppType = T;
using CType = T*;
- static GType value_type() G_GNUC_CONST;
+ static GType value_type();
inline void set(const CppType& data);
inline CppType get() const;
diff --git a/glib/src/bytearray.hg b/glib/src/bytearray.hg
index cf222b2..0ec3bd6 100644
--- a/glib/src/bytearray.hg
+++ b/glib/src/bytearray.hg
@@ -92,7 +92,7 @@ public:
_WRAP_METHOD(Glib::RefPtr<ByteArray> set_size(guint length), g_byte_array_set_size, refreturn)
#ifndef DOXYGEN_SHOULD_SKIP_THIS
- static GType get_type() G_GNUC_CONST;
+ static GType get_type();
#endif
};
diff --git a/glib/src/value_basictypes.h.m4 b/glib/src/value_basictypes.h.m4
index 8cd90e7..423cb9c 100644
--- a/glib/src/value_basictypes.h.m4
+++ b/glib/src/value_basictypes.h.m4
@@ -35,7 +35,7 @@ public:
using CppType = $1;
using CType = g$2;
- static GType value_type() G_GNUC_CONST;
+ static GType value_type();
void set($1 data);
$1 get() const;
diff --git a/glib/src/variant.hg b/glib/src/variant.hg
index 011aa99..e97f3de 100644
--- a/glib/src/variant.hg
+++ b/glib/src/variant.hg
@@ -484,7 +484,7 @@ public:
* @return The VariantType.
* @newin{2,28}
*/
- static const VariantType& variant_type() G_GNUC_CONST;
+ static const VariantType& variant_type();
//This must have a create() method because otherwise it would be a copy
//constructor.
@@ -536,7 +536,7 @@ public:
* @return The VariantType.
* @newin{2,36}
*/
- static const VariantType& variant_type() G_GNUC_CONST;
+ static const VariantType& variant_type();
/** Creates a new Variant< Variant<T> >.
* @param data The value of the new Variant.
@@ -581,7 +581,7 @@ public:
* @return The VariantType.
* @newin{2,28}
*/
- static const VariantType& variant_type() G_GNUC_CONST;
+ static const VariantType& variant_type();
/** Creates a new Variant<Glib::ustring>.
* @param data The value of the new Variant.
@@ -632,7 +632,7 @@ public:
* @return The VariantType.
* @newin{2,54}
*/
- static const VariantType& variant_type() G_GNUC_CONST;
+ static const VariantType& variant_type();
/** Creates a new Variant<Glib::DBusObjectPathString>.
* @param data The value of the new Variant.
@@ -678,7 +678,7 @@ public:
* @return The VariantType.
* @newin{2,54}
*/
- static const VariantType& variant_type() G_GNUC_CONST;
+ static const VariantType& variant_type();
/** Creates a new Variant<Glib::DBusSignatureString>.
* @param data The value of the new Variant.
@@ -725,7 +725,7 @@ public:
* @return The VariantType.
* @newin{2,28}
*/
- static const VariantType& variant_type() G_GNUC_CONST;
+ static const VariantType& variant_type();
/** Creates a new Variant<std::string>.
* @param data The value of the new Variant.
@@ -775,7 +775,7 @@ public:
* @return The VariantType.
* @newin{2,28}
*/
- static const VariantType& variant_type() G_GNUC_CONST;
+ static const VariantType& variant_type();
/** Creates a new Variant< std::pair<K, V> >.
* @param data The value of the new Variant.
@@ -824,7 +824,7 @@ public:
* @return The VariantType.
* @newin{2,28}
*/
- static const VariantType& variant_type() G_GNUC_CONST;
+ static const VariantType& variant_type();
/** Creates a new Variant from an array of numeric types.
* @param data The array to use for creation.
@@ -888,7 +888,7 @@ public:
* @return The VariantType.
* @newin{2,28}
*/
- static const VariantType& variant_type() G_GNUC_CONST;
+ static const VariantType& variant_type();
/** Creates a new Variant from an array of strings.
* @param data The array to use for creation.
@@ -952,7 +952,7 @@ public:
* @return The VariantType.
* @newin{2,54}
*/
- static const VariantType& variant_type() G_GNUC_CONST;
+ static const VariantType& variant_type();
/** Creates a new Variant from an array of strings.
* @param data The array to use for creation.
@@ -1014,7 +1014,7 @@ public:
* @return The VariantType.
* @newin{2,28}
*/
- static const VariantType& variant_type() G_GNUC_CONST;
+ static const VariantType& variant_type();
/** Creates a new Variant from an array of strings.
* @param data The array to use for creation.
@@ -1095,7 +1095,7 @@ public:
* @return The VariantType.
* @newin{2,28}
*/
- static const VariantType& variant_type() G_GNUC_CONST;
+ static const VariantType& variant_type();
/** Creates a new Variant containing a dictionary from a map.
* @param data The map to use for creation.
@@ -1173,7 +1173,7 @@ public:
* @return The VariantType.
* @newin{2,54}
*/
- static const VariantType& variant_type() G_GNUC_CONST;
+ static const VariantType& variant_type();
/** Gets a specific element from the tuple.
* It is an error if @a index is greater than or equal to the number of
diff --git a/glib/src/variant_basictypes.h.m4 b/glib/src/variant_basictypes.h.m4
index f73992f..cdf016e 100644
--- a/glib/src/variant_basictypes.h.m4
+++ b/glib/src/variant_basictypes.h.m4
@@ -62,7 +62,7 @@ public:
/** Gets the Glib::VariantType.
* @return The Glib::VariantType.
*/
- static const VariantType& variant_type() G_GNUC_CONST;
+ static const VariantType& variant_type();
/** Creates a new Glib::Variant<$1>.
* @param data The value of the new Glib::Variant<$1>.
diff --git a/tools/m4/class_boxedtype.m4 b/tools/m4/class_boxedtype.m4
index 4c2092b..fdbdad1 100644
--- a/tools/m4/class_boxedtype.m4
+++ b/tools/m4/class_boxedtype.m4
@@ -208,7 +208,7 @@ public:
/** Get the GType for this class, for use with the underlying GObject type system.
*/
- static GType get_type() G_GNUC_CONST;
+ static GType get_type();
ifdef(`__BOOL_CUSTOM_DEFAULT_CTOR__',`dnl
',`dnl else
diff --git a/tools/m4/class_boxedtype_static.m4 b/tools/m4/class_boxedtype_static.m4
index bbb3441..b036412 100644
--- a/tools/m4/class_boxedtype_static.m4
+++ b/tools/m4/class_boxedtype_static.m4
@@ -183,7 +183,7 @@ public:
/** Get the GType for this class, for use with the underlying GObject type system.
*/
- static GType get_type() G_GNUC_CONST;
+ static GType get_type();
ifdef(`__BOOL_CUSTOM_DEFAULT_CTOR__',,`dnl else
__CPPNAME__`'();
diff --git a/tools/m4/class_gobject.m4 b/tools/m4/class_gobject.m4
index 62b638b..cdebc0a 100644
--- a/tools/m4/class_gobject.m4
+++ b/tools/m4/class_gobject.m4
@@ -298,14 +298,14 @@ _IMPORT(SECTION_DTOR_DOCUMENTATION)
/** Get the GType for this class, for use with the underlying GObject type system.
*/
- static GType get_type() G_GNUC_CONST;
+ static GType get_type();
#ifndef DOXYGEN_SHOULD_SKIP_THIS
ifdef(`__BOOL_DYNAMIC_GTYPE_REGISTRATION__',`
static GType get_type(GTypeModule* module);
',`')
- static GType get_base_type() G_GNUC_CONST;
+ static GType get_base_type();
#endif
///Provides access to the underlying C GObject.
diff --git a/tools/m4/class_interface.m4 b/tools/m4/class_interface.m4
index aec8916..6531899 100644
--- a/tools/m4/class_interface.m4
+++ b/tools/m4/class_interface.m4
@@ -292,10 +292,10 @@ _IMPORT(SECTION_DTOR_DOCUMENTATION)
/** Get the GType for this class, for use with the underlying GObject type system.
*/
- static GType get_type() G_GNUC_CONST;
+ static GType get_type();
#ifndef DOXYGEN_SHOULD_SKIP_THIS
- static GType get_base_type() G_GNUC_CONST;
+ static GType get_base_type();
#endif
///Provides access to the underlying C GObject.
diff --git a/tools/m4/class_opaque_refcounted.m4 b/tools/m4/class_opaque_refcounted.m4
index 2a5b913..7ffe7c1 100644
--- a/tools/m4/class_opaque_refcounted.m4
+++ b/tools/m4/class_opaque_refcounted.m4
@@ -186,7 +186,7 @@ public:
ifdef(`__OPAQUE_FUNC_GTYPE__',`dnl
/** Get the GType for this class, for use with the underlying GObject type system.
*/
- static GType get_type() G_GNUC_CONST;
+ static GType get_type();
')dnl endif __OPAQUE_FUNC_GTYPE__
ifelse(__OPAQUE_FUNC_NEW,NONE,`dnl
diff --git a/tools/m4/enum.m4 b/tools/m4/enum.m4
index a2d5ecd..551b1a6 100644
--- a/tools/m4/enum.m4
+++ b/tools/m4/enum.m4
@@ -83,7 +83,7 @@ template <>
class $8 Value<__NAMESPACE__::__ENUM_CPPNAME__> : public __ENUM_VALUE_BASE__
{
public:
- static GType value_type() G_GNUC_CONST;
+ static GType value_type();
};
ifelse(`$7',,,`_DEPRECATE_IFDEF_END')`'dnl
diff --git a/tools/m4/gerror.m4 b/tools/m4/gerror.m4
index 787db0e..f886374 100644
--- a/tools/m4/gerror.m4
+++ b/tools/m4/gerror.m4
@@ -55,7 +55,7 @@ template <>
class $9 Value<__NAMESPACE__::__CPPNAME__::Code> : public __VALUE_BASE__
{
public:
- static GType value_type() G_GNUC_CONST;
+ static GType value_type();
};
ifelse(`$8',,,`_DEPRECATE_IFDEF_END')`'dnl
--
2.55.0