RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 609213 - instantiate a function
Summary: instantiate a function
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: gcc
Version: 6.2
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Jakub Jelinek
QA Contact: qe-baseos-tools-bugs
URL:
Whiteboard:
Depends On:
Blocks:
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:
Clone Of:
Environment:
Last Closed: 2011-12-16 19:39:15 UTC
Target Upstream Version:
Embargoed:


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
To: 	woodard9
Subject: 	g++ __attribute__ ((used))
Date: 	06/25/2010 01:28:59 PM



Hi,

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?

Thanks,
-Jeff

From: 	Ben Woodard <bwoodard>
To: 	keasler1
Cc: 	woodard9
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
code. 

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.

-ben

From: 	keasler1
To: 	Ben Woodard <bwoodard>
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  
instantiated.

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.

-Jeff

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