Bug 34735 - C99 6.7.4/3 is not diagnose
Summary: C99 6.7.4/3 is not diagnose
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Keywords: accepts-invalid
Depends on:
Blocks: 16989 16622
  Show dependency treegraph
Reported: 2008-01-11 04:37 UTC by Andrew Pinski
Modified: 2008-01-14 00:55 UTC (History)
1 user (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed: 2008-01-11 09:28:29


Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Pinski 2008-01-11 04:37:45 UTC
This is not rejected:
static int a()
  return 0;

extern int f(void);

inline int f(void)
  return a();

---- CUT ---

This violates C99 6.7.4/2 which says:
An inline definition of a function with external linkage shall not contain a definition of a
modifiable object with static storage duration, and shall not contain a reference to an
identifier with internal linkage.
Comment 1 Andrew Pinski 2008-01-11 05:15:45 UTC
We do reject this though:
static int a()
  return 0;
inline int f(void)
  return a();
extern int f(void);
Comment 2 Richard Biener 2008-01-11 09:28:29 UTC
Comment 3 Geoff Keating 2008-01-14 00:55:34 UTC
The quoted paragraph does not apply to the first code example, because an "inline definition" is defined in paragraph 6 as:

If all of the file scope declarations for a function in a translation unit include the inline function specifier without extern, then the definition in that translation unit is an inline definition.

In this case, one of the declarations does not include the inline function specifier, so it's not an inline definition.

I am unclear on how the standard is supposed to apply to the second example, but IMO we should give the warning anyway.