Thread View: comp.std.c++
4 messages
4 total messages
Started by Alexsander Krotoff
Wed, 18 Oct 1995 16:15
static in inline
Author: Alexsander Krotoff
Date: Wed, 18 Oct 1995 16:15
Date: Wed, 18 Oct 1995 16:15
26 lines
1586 bytes
1586 bytes
Hello C++ gurus, I know, this question is asked here some time ago, but I found no changes in the October Working Draft and want to ask it again. If the the static variable is defined in the body of `inline' function, and compiler sucseed to substitute function body sevral times, shall these function copyes share common static variable? What is about initialization of this static variable with non-constant? What shall happen, if the function body is defined and substituted in the number of compilation units? If it was discussed before, are there any summary ? Is it indeed well-defined in the working paper ? Thank you. -- Alexander N. Krotoff <krotoff@such.srcc.msu.su> Research Computer Center [Moscow]939-2638 Moscow State University MGU, SRCC room 316 [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Re: static in inline
Author: john (j.d.) hickin
Date: Thu, 19 Oct 1995 16:49
Date: Thu, 19 Oct 1995 16:49
18 lines
1329 bytes
1329 bytes
I won't quote from the standard because I don't have a copy. I will, however, express my opinion on what behavior makes sense. The inline keyword is just a compiler hint and the implementation may choose to ignore a hint at its discretion. The case in hand is one where the compiler must treat the case as an error (as, for example, does cfront) or where it must bend over backwards to insure that only one version of the static variable is produced. This latter approach is too subtle for my liking, as you get into initialization problems as your posting has implied. -- John Hickin Bell-Northern Research, Montreal, Quebec (514) 765-7924 hickin@bnr.ca --- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Re: static in inline
Author: John Max Skaller
Date: Sun, 22 Oct 1995 07:00
Date: Sun, 22 Oct 1995 07:00
34 lines
1556 bytes
1556 bytes
krotoff@boy.nmd.msu.ru (Alexsander Krotoff) wrote:
>Hello C++ gurus,
>
>I know, this question is asked here some time ago, but I found
>no changes in the October Working Draft and want to ask it again.
>
>If the the static variable is defined in the body of `inline'
>function, and compiler sucseed to substitute function body
>sevral times, shall these function copyes share common
>static variable?
Yes. And AFAIK the appropriate words ARE in the latest WP.
>What is about initialization of this static
>variable with non-constant? What shall happen, if the function
>body is defined and substituted in the number of compilation
>units?
Thats the implementors problem.
--
John Max Skaller voice: 61-2-566-2189
81 Glebe Point Rd fax: 61-2-660-0850
GLEBE NSW 2037 email: maxtal@suphys.physics.oz.au
AUSTRALIA email: skaller@maxtal.com.au
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Re: static in inline
Author: Fergus Henderson
Date: Mon, 23 Oct 1995 17:38
Date: Mon, 23 Oct 1995 17:38
37 lines
1837 bytes
1837 bytes
krotoff@boy.nmd.msu.ru (Alexsander Krotoff) writes: >If the the static variable is defined in the body of `inline' >function, and compiler sucseed to substitute function body >sevral times, shall these function copyes share common >static variable? Yes. >What is about initialization of this static >variable with non-constant? It had better get initialized only once. >What shall happen, if the function >body is defined and substituted in the number of compilation >units? If it was a member function, or it was declared as `extern inline', then each of the definitions must be identical (as defined by the ODR), and there is still only one variable, which must get initialized at most once. Each instance of the function refers to the same static variable. If the function was not a member function, then linkage defaults to static, and so if it is not explicitly specified as `extern' then each translation unit gets its own copy of the function, each of which has its own static variable. (However, multiple calls to the same inline function from within the same translation unit will all refer to the same copy of any local static variables.) --- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads