[Bug 1234218] [NEW] 4.8 doesn't throw -Wreturn-type anymore for wrong returns in macros

Lars Uebernickel lars.uebernickel at canonical.com
Wed Oct 2 14:33:07 UTC 2013


Public bug reported:

GLib has a macro g_return_if_fail(), that returns from a function when a
precondition isn't met. gcc used to warn when calling it in a function
that returns a value, but stopped doing so in 4.8.

$ cat return-warning.c

#include <glib.h>

int function (int c)
{
  g_return_if_fail (c > 100);
}
$ gcc-4.7 -c -Wreturn-type `pkg-config --cflags glib-2.0` return-warning.c 
return-warning.c: In function ‘function’:
return-warning.c:6:3: warning: ‘return’ with no value, in function returning non-void [-Wreturn-type]
$ gcc-4.8 -c -Wreturn-type `pkg-config --cflags glib-2.0` return-warning.c 
$

** Affects: gcc-4.8 (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gcc-4.8 in Ubuntu.
https://bugs.launchpad.net/bugs/1234218

Title:
  4.8 doesn't throw -Wreturn-type anymore for wrong returns in macros

Status in “gcc-4.8” package in Ubuntu:
  New

Bug description:
  GLib has a macro g_return_if_fail(), that returns from a function when
  a precondition isn't met. gcc used to warn when calling it in a
  function that returns a value, but stopped doing so in 4.8.

  $ cat return-warning.c

  #include <glib.h>

  int function (int c)
  {
    g_return_if_fail (c > 100);
  }
  $ gcc-4.7 -c -Wreturn-type `pkg-config --cflags glib-2.0` return-warning.c 
  return-warning.c: In function ‘function’:
  return-warning.c:6:3: warning: ‘return’ with no value, in function returning non-void [-Wreturn-type]
  $ gcc-4.8 -c -Wreturn-type `pkg-config --cflags glib-2.0` return-warning.c 
  $

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-4.8/+bug/1234218/+subscriptions



More information about the foundations-bugs mailing list