public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/39026] New: Gcc accepts invalid code
@ 2009-01-29 18:31 hjl dot tools at gmail dot com
2009-01-29 18:34 ` [Bug c/39026] " hjl dot tools at gmail dot com
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: hjl dot tools at gmail dot com @ 2009-01-29 18:31 UTC (permalink / raw)
To: gcc-bugs
+++ This bug was initially created as a clone of Bug #39013 +++
[hjl@gnu-6 gcc]$ cat /tmp/i.i
inline void foo ();
int
main ()
{
foo ();
return 0;
}
[hjl@gnu-6 gcc]$ gcc /tmp/i.i -S
Is this valid C code? From
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39013#c10
--
IMHO this is invalid. 6.7.4/6
"... If a function is declared with an inline function specifier, then it
shall also be defined in the same translation unit."
--
--
Summary: Gcc accepts invalid code
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: hjl dot tools at gmail dot com
BugsThisDependsOn: 39013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39026
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/39026] Gcc accepts invalid code
2009-01-29 18:31 [Bug c/39026] New: Gcc accepts invalid code hjl dot tools at gmail dot com
@ 2009-01-29 18:34 ` hjl dot tools at gmail dot com
2009-01-29 20:02 ` joseph at codesourcery dot com
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: hjl dot tools at gmail dot com @ 2009-01-29 18:34 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from hjl dot tools at gmail dot com 2009-01-29 18:34 -------
Icc 11.0 gave:
[hjl@gnu-6 tmp]$ /opt/intel/cce/11.0/bin/icc -S i.i -Wall
i.i(1): remark #1419: external declaration in primary source file
inline void foo ();
^
[hjl@gnu-6 tmp]$ /opt/intel/cce/11.0/bin/icc -S i.i
[hjl@gnu-6 tmp]$
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39026
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/39026] Gcc accepts invalid code
2009-01-29 18:31 [Bug c/39026] New: Gcc accepts invalid code hjl dot tools at gmail dot com
2009-01-29 18:34 ` [Bug c/39026] " hjl dot tools at gmail dot com
@ 2009-01-29 20:02 ` joseph at codesourcery dot com
2009-01-29 20:09 ` hjl dot tools at gmail dot com
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: joseph at codesourcery dot com @ 2009-01-29 20:02 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from joseph at codesourcery dot com 2009-01-29 20:02 -------
Subject: Re: New: Gcc accepts invalid code
On Thu, 29 Jan 2009, hjl dot tools at gmail dot com wrote:
> inline void foo ();
>
> int
> main ()
> {
> foo ();
> return 0;
> }
> [hjl@gnu-6 gcc]$ gcc /tmp/i.i -S
If you use -std=c99 -pedantic-errors you get an error, as expected.
You're compiling in gnu89 mode.
If you use -std=c99 without -pedantic-errors you get a duplicate warning:
t.c:1: warning: inline function 'foo' declared but never defined
t.c:1: warning: inline function 'foo' declared but never defined
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39026
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/39026] Gcc accepts invalid code
2009-01-29 18:31 [Bug c/39026] New: Gcc accepts invalid code hjl dot tools at gmail dot com
2009-01-29 18:34 ` [Bug c/39026] " hjl dot tools at gmail dot com
2009-01-29 20:02 ` joseph at codesourcery dot com
@ 2009-01-29 20:09 ` hjl dot tools at gmail dot com
2009-01-29 20:09 ` [Bug c/39026] New: " Joseph S. Myers
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: hjl dot tools at gmail dot com @ 2009-01-29 20:09 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from hjl dot tools at gmail dot com 2009-01-29 20:09 -------
(In reply to comment #2)
> If you use -std=c99 -pedantic-errors you get an error, as expected.
> You're compiling in gnu89 mode.
>
> If you use -std=c99 without -pedantic-errors you get a duplicate warning:
>
> t.c:1: warning: inline function 'foo' declared but never defined
> t.c:1: warning: inline function 'foo' declared but never defined
>
So the code is valid in gnu89 mode, which is the default. With -std=c99
and without -pedantic-errors, shouldn't we generate working binary?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39026
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Bug c/39026] New: Gcc accepts invalid code
2009-01-29 18:31 [Bug c/39026] New: Gcc accepts invalid code hjl dot tools at gmail dot com
` (2 preceding siblings ...)
2009-01-29 20:09 ` hjl dot tools at gmail dot com
@ 2009-01-29 20:09 ` Joseph S. Myers
2009-01-29 21:24 ` [Bug c/39026] " rguenther at suse dot de
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Joseph S. Myers @ 2009-01-29 20:09 UTC (permalink / raw)
To: hjl dot tools at gmail dot com; +Cc: gcc-bugs
On Thu, 29 Jan 2009, hjl dot tools at gmail dot com wrote:
> inline void foo ();
>
> int
> main ()
> {
> foo ();
> return 0;
> }
> [hjl@gnu-6 gcc]$ gcc /tmp/i.i -S
If you use -std=c99 -pedantic-errors you get an error, as expected.
You're compiling in gnu89 mode.
If you use -std=c99 without -pedantic-errors you get a duplicate warning:
t.c:1: warning: inline function 'foo' declared but never defined
t.c:1: warning: inline function 'foo' declared but never defined
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/39026] Gcc accepts invalid code
2009-01-29 18:31 [Bug c/39026] New: Gcc accepts invalid code hjl dot tools at gmail dot com
` (3 preceding siblings ...)
2009-01-29 20:09 ` [Bug c/39026] New: " Joseph S. Myers
@ 2009-01-29 21:24 ` rguenther at suse dot de
2009-01-30 1:17 ` hjl dot tools at gmail dot com
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenther at suse dot de @ 2009-01-29 21:24 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from rguenther at suse dot de 2009-01-29 21:24 -------
Subject: Re: Gcc accepts invalid code
On Thu, 29 Jan 2009, joseph at codesourcery dot com wrote:
>
>
> ------- Comment #2 from joseph at codesourcery dot com 2009-01-29 20:02 -------
> Subject: Re: New: Gcc accepts invalid code
>
> On Thu, 29 Jan 2009, hjl dot tools at gmail dot com wrote:
>
> > inline void foo ();
> >
> > int
> > main ()
> > {
> > foo ();
> > return 0;
> > }
> > [hjl@gnu-6 gcc]$ gcc /tmp/i.i -S
>
> If you use -std=c99 -pedantic-errors you get an error, as expected.
> You're compiling in gnu89 mode.
>
> If you use -std=c99 without -pedantic-errors you get a duplicate warning:
>
> t.c:1: warning: inline function 'foo' declared but never defined
> t.c:1: warning: inline function 'foo' declared but never defined
I think the frontend should, in C89 mode and if just issueing a warning,
set DECL_EXTERNAL properly on the decl.
Richard.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39026
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/39026] Gcc accepts invalid code
2009-01-29 18:31 [Bug c/39026] New: Gcc accepts invalid code hjl dot tools at gmail dot com
` (4 preceding siblings ...)
2009-01-29 21:24 ` [Bug c/39026] " rguenther at suse dot de
@ 2009-01-30 1:17 ` hjl dot tools at gmail dot com
2009-01-30 6:52 ` rguenther at suse dot de
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: hjl dot tools at gmail dot com @ 2009-01-30 1:17 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from hjl dot tools at gmail dot com 2009-01-30 01:17 -------
(In reply to comment #4)
>
> I think the frontend should, in C89 mode and if just issueing a warning,
> set DECL_EXTERNAL properly on the decl.
>
Do we want to make such a change, especially for 4.3 branch?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39026
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/39026] Gcc accepts invalid code
2009-01-29 18:31 [Bug c/39026] New: Gcc accepts invalid code hjl dot tools at gmail dot com
` (5 preceding siblings ...)
2009-01-30 1:17 ` hjl dot tools at gmail dot com
@ 2009-01-30 6:52 ` rguenther at suse dot de
2009-01-30 16:05 ` hjl dot tools at gmail dot com
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenther at suse dot de @ 2009-01-30 6:52 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from rguenther at suse dot de 2009-01-30 06:52 -------
Subject: Re: Gcc accepts invalid code
On Fri, 30 Jan 2009, hjl dot tools at gmail dot com wrote:
> ------- Comment #5 from hjl dot tools at gmail dot com 2009-01-30 01:17 -------
> (In reply to comment #4)
> >
> > I think the frontend should, in C89 mode and if just issueing a warning,
> > set DECL_EXTERNAL properly on the decl.
> >
>
> Do we want to make such a change, especially for 4.3 branch?
It would be a way more local change than changing what binds local
(which also affects other languages). Did you try to track down which
change broke this in the first place?
Richard.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39026
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/39026] Gcc accepts invalid code
2009-01-29 18:31 [Bug c/39026] New: Gcc accepts invalid code hjl dot tools at gmail dot com
` (6 preceding siblings ...)
2009-01-30 6:52 ` rguenther at suse dot de
@ 2009-01-30 16:05 ` hjl dot tools at gmail dot com
2009-01-30 16:44 ` hjl dot tools at gmail dot com
2009-01-31 17:44 ` hjl dot tools at gmail dot com
9 siblings, 0 replies; 11+ messages in thread
From: hjl dot tools at gmail dot com @ 2009-01-30 16:05 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from hjl dot tools at gmail dot com 2009-01-30 16:04 -------
I think it is caused by revision 118356:
http://gcc.gnu.org/ml/gcc-cvs/2006-11/msg00007.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39026
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/39026] Gcc accepts invalid code
2009-01-29 18:31 [Bug c/39026] New: Gcc accepts invalid code hjl dot tools at gmail dot com
` (7 preceding siblings ...)
2009-01-30 16:05 ` hjl dot tools at gmail dot com
@ 2009-01-30 16:44 ` hjl dot tools at gmail dot com
2009-01-31 17:44 ` hjl dot tools at gmail dot com
9 siblings, 0 replies; 11+ messages in thread
From: hjl dot tools at gmail dot com @ 2009-01-30 16:44 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from hjl dot tools at gmail dot com 2009-01-30 16:44 -------
(In reply to comment #6)
>
> It would be a way more local change than changing what binds local
> (which also affects other languages).
My proposal patch will bind undefined functions global, instead of
local. It sounds safe to me. We can put it on trunk and wait a while
before backporting it to 4.3 branch.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39026
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/39026] Gcc accepts invalid code
2009-01-29 18:31 [Bug c/39026] New: Gcc accepts invalid code hjl dot tools at gmail dot com
` (8 preceding siblings ...)
2009-01-30 16:44 ` hjl dot tools at gmail dot com
@ 2009-01-31 17:44 ` hjl dot tools at gmail dot com
9 siblings, 0 replies; 11+ messages in thread
From: hjl dot tools at gmail dot com @ 2009-01-31 17:44 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from hjl dot tools at gmail dot com 2009-01-31 17:43 -------
The code is valid in gnu89 mode.
--
hjl dot tools at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39026
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2009-01-31 17:44 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-29 18:31 [Bug c/39026] New: Gcc accepts invalid code hjl dot tools at gmail dot com
2009-01-29 18:34 ` [Bug c/39026] " hjl dot tools at gmail dot com
2009-01-29 20:02 ` joseph at codesourcery dot com
2009-01-29 20:09 ` hjl dot tools at gmail dot com
2009-01-29 20:09 ` [Bug c/39026] New: " Joseph S. Myers
2009-01-29 21:24 ` [Bug c/39026] " rguenther at suse dot de
2009-01-30 1:17 ` hjl dot tools at gmail dot com
2009-01-30 6:52 ` rguenther at suse dot de
2009-01-30 16:05 ` hjl dot tools at gmail dot com
2009-01-30 16:44 ` hjl dot tools at gmail dot com
2009-01-31 17:44 ` hjl dot tools at gmail dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).