public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/19238] New: cannot change visibility of static variable in function template
@ 2005-01-03 10:52 jbeulich at novell dot com
  2005-01-03 11:05 ` [Bug c++/19238] " giovannibajo at libero dot it
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: jbeulich at novell dot com @ 2005-01-03 10:52 UTC (permalink / raw)
  To: gcc-bugs

Since handle_visibility_attribute as its very first action checks
decl_function_context (decl) != 0, and since the visibility attribute of the
function template does not get inherited to its static variables, there is no
way to actually limit the visibility of these static variables.
This in turn prevents on IA64 that the variable be accessed without going
through the linkage table at all (i.e. even saving the pointless instruction
resulting from the linker conversion of ltoff22x/ldxmov).
Along with that, it might even lead to ill behavior since the containing
function instances can't be overridden by identically named ones in a different
load module, but the static variables (being weak, but not visibility
restricted) can.

-- 
           Summary: cannot change visibility of static variable in function
                    template
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jbeulich at novell dot com
                CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: ia64-*-*


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


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

* [Bug c++/19238] cannot change visibility of static variable in function template
  2005-01-03 10:52 [Bug c++/19238] New: cannot change visibility of static variable in function template jbeulich at novell dot com
@ 2005-01-03 11:05 ` giovannibajo at libero dot it
  2005-01-03 12:47 ` jbeulich at novell dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: giovannibajo at libero dot it @ 2005-01-03 11:05 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2005-01-03 11:05 -------
We need a testcase, and a suggestion for the behaviour you are expecting of GCC.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING


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


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

* [Bug c++/19238] cannot change visibility of static variable in function template
  2005-01-03 10:52 [Bug c++/19238] New: cannot change visibility of static variable in function template jbeulich at novell dot com
  2005-01-03 11:05 ` [Bug c++/19238] " giovannibajo at libero dot it
@ 2005-01-03 12:47 ` jbeulich at novell dot com
  2005-01-03 13:00 ` giovannibajo at libero dot it
  2005-01-03 16:14 ` mmitchel at gcc dot gnu dot org
  3 siblings, 0 replies; 8+ messages in thread
From: jbeulich at novell dot com @ 2005-01-03 12:47 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jbeulich at novell dot com  2005-01-03 12:47 -------
I'm sorry, test case below. The expectation would be that the visibility
attribute gets inherited (as described above) from function template instances
and member functions of class template instances to their static variables.
If that conflicts with anything I can't think of right now, then the backup
solution would be to allow the attribute on such objects.

unsigned gu;

template<typename T> T test() __attribute__((__visibility__("hidden")));
template<typename T> T test() {
	static T st;

	return st = gu;
}

void test() {
	test<unsigned>();
}


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW
     Ever Confirmed|                            |1


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


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

* [Bug c++/19238] cannot change visibility of static variable in function template
  2005-01-03 10:52 [Bug c++/19238] New: cannot change visibility of static variable in function template jbeulich at novell dot com
  2005-01-03 11:05 ` [Bug c++/19238] " giovannibajo at libero dot it
  2005-01-03 12:47 ` jbeulich at novell dot com
@ 2005-01-03 13:00 ` giovannibajo at libero dot it
  2005-01-03 16:14 ` mmitchel at gcc dot gnu dot org
  3 siblings, 0 replies; 8+ messages in thread
From: giovannibajo at libero dot it @ 2005-01-03 13:00 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2005-01-03 13:00 -------
Mark did some work on the visibility stuff, so I'm CC'ing him. Mark, this 
sounds like a reasonable request to me. What do you think?

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |giovannibajo at libero dot
                   |                            |it, mmitchel at gcc dot gnu
                   |                            |dot org


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


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

* [Bug c++/19238] cannot change visibility of static variable in function template
  2005-01-03 10:52 [Bug c++/19238] New: cannot change visibility of static variable in function template jbeulich at novell dot com
                   ` (2 preceding siblings ...)
  2005-01-03 13:00 ` giovannibajo at libero dot it
@ 2005-01-03 16:14 ` mmitchel at gcc dot gnu dot org
  3 siblings, 0 replies; 8+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-01-03 16:14 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2005-01-03 16:14 -------
Yes, I agree that it seems logical for a static variable to have the same
visibility as its containing function, independently of whether or not that
containing function is a template instance.

-- 


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


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

* [Bug c++/19238] cannot change visibility of static variable in function template
       [not found] <bug-19238-1068@http.gcc.gnu.org/bugzilla/>
  2006-03-21  2:49 ` jason at gcc dot gnu dot org
  2006-03-21  3:19 ` jason at gcc dot gnu dot org
@ 2006-03-21 16:33 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-21 16:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pinskia at gcc dot gnu dot org  2006-03-21 16:32 -------
Fixed.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.2.0


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


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

* [Bug c++/19238] cannot change visibility of static variable in function template
       [not found] <bug-19238-1068@http.gcc.gnu.org/bugzilla/>
  2006-03-21  2:49 ` jason at gcc dot gnu dot org
@ 2006-03-21  3:19 ` jason at gcc dot gnu dot org
  2006-03-21 16:33 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu dot org @ 2006-03-21  3:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from jason at gcc dot gnu dot org  2006-03-21 03:19 -------
Subject: Bug 19238

Author: jason
Date: Tue Mar 21 03:19:06 2006
New Revision: 112239

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=112239
Log:
        PR c++/21764
        * c-pragma.c (visstack): Move out of handle_pragma_visibility.
        (push_visibility, pop_visibility): Likewise.
        * c-pragma.h: Declare them.
        * cp/name-lookup.h (struct cp_binding_level): Add has_visibility
        bitfield.
        * cp/name-lookup.c: Include c-pragma.h.
        (push_namespace_with_attribs): Split out from push_namespace.
        Push visibility if appropriate.  Set TREE_PUBLIC on namespaces.
        (leave_scope): Pop visibility if appropriate.
        * cp/parser.c (cp_parser_declaration, cp_parser_namespace_name): Allow
        attributes on namespace declarations.

        PR c++/19238
        * cp/decl.c (cp_finish_decl): Call determine_visibility later.
        (start_preparsed_function): Likewise.
        * cp/cp-tree.h (CP_TYPE_CONTEXT, TYPE_NAMESPACE_SCOPE_P): New macros.
        (TYPE_CLASS_SCOPE_P, TYPE_FUNCTION_SCOPE_P): New macros.
        * cp/decl2.c (determine_visibility_from_class): Split out from...
        (determine_visibility): ...here.  Handle function scope and
        nested classes.
        (import_export_decl): Move visibility handling to
        determine_visibility_from_class.

Added:
    trunk/gcc/testsuite/g++.dg/ext/visibility/local1.C
    trunk/gcc/testsuite/g++.dg/ext/visibility/namespace1.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-pragma.c
    trunk/gcc/c-pragma.h
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/decl2.c
    trunk/gcc/cp/name-lookup.c
    trunk/gcc/cp/name-lookup.h
    trunk/gcc/cp/parser.c


-- 


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


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

* [Bug c++/19238] cannot change visibility of static variable in function template
       [not found] <bug-19238-1068@http.gcc.gnu.org/bugzilla/>
@ 2006-03-21  2:49 ` jason at gcc dot gnu dot org
  2006-03-21  3:19 ` jason at gcc dot gnu dot org
  2006-03-21 16:33 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu dot org @ 2006-03-21  2:49 UTC (permalink / raw)
  To: gcc-bugs



-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jason at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2005-12-28 20:29:56         |2006-03-21 02:49:27
               date|                            |


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


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

end of thread, other threads:[~2006-03-21 16:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-03 10:52 [Bug c++/19238] New: cannot change visibility of static variable in function template jbeulich at novell dot com
2005-01-03 11:05 ` [Bug c++/19238] " giovannibajo at libero dot it
2005-01-03 12:47 ` jbeulich at novell dot com
2005-01-03 13:00 ` giovannibajo at libero dot it
2005-01-03 16:14 ` mmitchel at gcc dot gnu dot org
     [not found] <bug-19238-1068@http.gcc.gnu.org/bugzilla/>
2006-03-21  2:49 ` jason at gcc dot gnu dot org
2006-03-21  3:19 ` jason at gcc dot gnu dot org
2006-03-21 16:33 ` pinskia at gcc dot gnu dot 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).