This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Hi,
MySQL team have updated their code to respect ISO-C++ paragraph 7.1.2.4, but
it still doesn't compile.
I join to this mail the ii file of new item_sum.cc (where mark_as_sum_func
function is) and of sql_yacc.cc (from where the error occurs during the
link).
Thanks and regards,
Jocelyn Fournier
----- Original Message -----
From: <reichelt@igpm.rwth-aachen.de>
To: <gcc-bugs@gcc.gnu.org>; <gcc-prs@gcc.gnu.org>; <joc@presence-pc.com>;
<nobody@gcc.gnu.org>
Sent: Friday, November 29, 2002 10:37 PM
Subject: Re: c++/8749: undefined reference error when declaring a function
as inline and using -O3 switch
> Synopsis: undefined reference error when declaring a function as inline
and using -O3 switch
>
> State-Changed-From-To: open->closed
> State-Changed-By: reichelt
> State-Changed-When: Fri Nov 29 13:37:15 2002
> State-Changed-Why:
> Not a bug.
>
> Paragraph 7.1.2.4 of the ISO-Standard states:
>
> An inline function shall be defined in every translation unit in which
it
> is used and shall have exactly the same definition in every case.
[...]
>
> As I understand it, you have a situation similar to the following:
>
> File1.cc:
> ----------------snip here----------------
> inline int foo (int x) { return x; }
>
> int bar() { return foo(2); }
> ----------------snip here----------------
>
> File2.cc:
> ----------------snip here----------------
> inline int foo (int);
>
> int main() { return foo(1); }
> ----------------snip here----------------
>
> If I compile this using "g++ File1.cc File2.cc" I get a working
program
> that returns 1. If I compile it with "-O" enabled, I get a linker
error:
>
> Unresolved text symbol "foo(int)" -- 1st referenced by
/var/tmp//cckhU7pa.o.
>
> Without optimization the function "foo" in the first file isn't
inlined.
> But because it's used by "bar" it is put in the object file. With
optimization
> the function is inlined and doesn't appear explicitly in the object
file of
> the first file. Therefore, the linker error.
>
> In essence: The compiler does not need to put inline functions in the
object
> file. The compiler can just optimize them away. And because of that we
have
> paragraph 7.1.2.4.
>
>
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&p
r=8749
>
>
>
Attachment:
inline.tar.gz
Description: Binary data
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |