Bug 609213 - instantiate a function
Summary: instantiate a function
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: gcc   
(Show other bugs)
Version: 6.2
Hardware: All
OS: Linux
Target Milestone: rc
: ---
Assignee: Jakub Jelinek
QA Contact: qe-baseos-tools
Depends On:
TreeView+ depends on / blocked
Reported: 2010-06-29 16:51 UTC by Issue Tracker
Modified: 2018-11-26 19:45 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2011-12-16 19:39:15 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

Description Issue Tracker 2010-06-29 16:51:59 UTC
Escalated to Bugzilla from IssueTracker

Comment 1 Issue Tracker 2010-06-29 16:52:01 UTC
Event posted on 2010-06-28 06:21 PDT by woodard

From: 	keasler1@llnl.gov
To: 	woodard9@llnl.gov
Subject: 	g++ __attribute__ ((used))
Date: 	06/25/2010 01:28:59 PM


I have a templated class-static member function that I need to compile  
into my code for use in the debugger.  I tried adding "__attribute__  
((used))" to the function declaration in the hope that would force  
template instantiation of the function whenever the user made an  
instantitation of the class (i.e. they called a constructor for the  
class with a given template signature somewhere in their code).   
Unfortunately, the "used" attribute is not being honored in this case.

My workaround has been to add the following code to all my constructors:

     if (this == NULL)
        func(this) ;

But this is very messy since each of my classes has tens of constructors.

Any comments or suggestions?


From: 	Ben Woodard <bwoodard@llnl.gov>
To: 	keasler1@llnl.gov
Cc: 	woodard9@llnl.gov
Subject: 	Re: g++ __attribute__ ((used))
Date: 	06/25/2010 03:10:04 PM

So first of all I need to make sure that I understand.

You want a particular static member function in a templated class to be
available so that you can call it from the debugger but it is never
called from the actual program. So the compiler eliminates it as dead

You want to prevent the function from ever being eliminated and you
hoped that "__attribute__ ((used))" would do that for you but it doesn't
seem to work.


From: 	keasler1@llnl.gov
To: 	Ben Woodard <bwoodard@llnl.gov>
Subject: 	Re: g++ __attribute__ ((used))
Date: 	06/25/2010 03:21:09 PM

Right.  However, I don't expect the static member function to be  
instantiated unless the templated class it is attached to is  

If you are on-site and can get into B453, I'd be happy to show you why  
this is important to not just me.


This event sent from IssueTracker by woodard  [LLNL (HPC)]
 issue 1070613

Comment 4 Ben Woodard 2011-05-13 13:19:26 UTC
Per customer request. Please make this BZ public.

Comment 10 Jakub Jelinek 2011-12-16 19:39:15 UTC
I believe this is already fixed in RHEL 6.2, under:
* Wed Aug 24 2011 Jakub Jelinek <jakub@redhat.com> 4.4.6-3
- support used attribute on template class methods and static data
  members for forced instantiation (#722587, PR c++/43125)

Note You need to log in before you can comment on or make changes to this bug.