public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/53532] New: function call ignored when called with argument of incompatible, undefined structure
@ 2012-05-30 16:52 machata at post dot cz
  2012-05-30 19:10 ` [Bug c/53532] " joseph at codesourcery dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: machata at post dot cz @ 2012-05-30 16:52 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53532

             Bug #: 53532
           Summary: function call ignored when called with argument of
                    incompatible, undefined structure
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: machata@post.cz


The following code...

struct aaa {};
extern int xxx(struct aaa e);
int main() {
  xxx((struct bbb) {});
  return 0;
}

... compiles without warnings and the call to xxx is ignored:
# gcc -Wall -Wextra -c foo.c
# objdump -x foo.o
[...]
Disassembly of section .text:
0000000000000000 <main>:
   0:    55                   push   %rbp
   1:    48 89 e5             mov    %rsp,%rbp
   4:    b8 00 00 00 00       mov    $0x0,%eax
   9:    5d                   pop    %rbp
   a:    c3                   retq
[...]

The code above seems invalid, and I think that gcc should reject it.

The definition of struct aaa is somehow important.  When dropped, GCC realizes
things are wrong, and complains abundantly.

# LANG=C gcc -Wall -Wextra -x c /dev/stdin
extern int xxx(struct aaa e);
int main() {
  xxx((struct bbb) {});
  return 0;
}
/dev/stdin:1:23: warning: 'struct aaa' declared inside parameter list [enabled
by default]
/dev/stdin:1:23: warning: its scope is only this definition or declaration,
which is probably not what you want [enabled by default]
/dev/stdin: In function 'main':
/dev/stdin:3:15: error: type of formal parameter 1 is incomplete

It also complains about struct bbb being incomplete, which it didn't mind at
all while aaa was there.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-10-17 20:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-30 16:52 [Bug c/53532] New: function call ignored when called with argument of incompatible, undefined structure machata at post dot cz
2012-05-30 19:10 ` [Bug c/53532] " joseph at codesourcery dot com
2012-05-31 12:10 ` jakub at gcc dot gnu.org
2012-06-12 21:16 ` jakub at gcc dot gnu.org
2013-02-19 20:38 ` LpSolit at netscape dot net
2013-10-17 20:24 ` mpolacek at gcc dot gnu.org
2013-10-17 20:24 ` mpolacek at gcc dot gnu.org

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).