Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
gobject-introspection
gobject-introspection
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 227
    • Issues 227
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 18
    • Merge Requests 18
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • GNOME
  • gobject-introspectiongobject-introspection
  • Issues
  • #123

Closed
Open
Opened Feb 23, 2015 by bugzilla-migration@bugzilla-migrationReporter

Warn when returning aggregates by value

Submitted by Philip Withnall @pwithnall

Link to original bug (#745002)

Description

g-ir-scanner should warn if C code returns an aggregate by value rather than by reference, since GIR appears to not support this currently. (Or, at least, pygobject appears not to support it and I’m not sure how other bindings could either.)

For example, given functions: cairo_rectangle_int_t *test_func1 (void); cairo_rectangle_int_t test_func2 (void);

The following GIR is generated, where the functions only differ in their c:type parameters: <return-value transfer-ownership="full"> </return-value> </function> <return-value transfer-ownership="full"> </return-value> </function>

The following Python test then crashes because the return value of func2() is interpreted as a cairo_rectangle_int_t* rather than a cairo_rectangle_int_t: from gi.repository import Test b = Test.func2() print("b: (wrong address): ", b) # wrong address print("b.x: (crash): ", b.x) # crashes

This was previously caught in some modules by using the -Waggregate-return compiler warning, but that’s fallen out of favour because it’s a pain for internal code.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: GNOME/gobject-introspection#123