Bug 490690 - g++ error with -fabi-version=1
g++ error with -fabi-version=1
Status: CLOSED WONTFIX
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: gcc4 (Show other bugs)
4.9
All Linux
high Severity high
: rc
: ---
Assigned To: Jakub Jelinek
qe-baseos-tools
: Regression
Depends On: 490211
Blocks:
  Show dependency treegraph
 
Reported: 2009-03-17 12:45 EDT by James M. Leddy
Modified: 2014-08-11 01:42 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 490211
Environment:
Last Closed: 2010-09-08 11:20:04 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description James M. Leddy 2009-03-17 12:45:36 EDT
+++ This bug was initially created as a clone of Bug #490211 +++

Description of problem:
g++ 4.1.x chokes on the attached code when using -fabi-version=1.  It works with abi versions 0 and 2, and g++ 3.x and 4.2 and newer work with all abi versions.

$ g++ -fabi-version=1 templtest.cc
templtest.cc: In constructor ‘S::S(U) [with U = int]’:
templtest.cc:27:   instantiated from here
templtest.cc:21: error: no matching function for call to ‘T::f(char [12])’
templtest.cc:6: note: candidates are: int T::f(char (&)[N]) const [with long unsigned int N = 12ul]


Version-Release number of selected component (if applicable):
gcc-4.1.2-44.el5.x86_64
gcc-c++-4.1.2-44.el5.x86_64

How reproducible:
every time

Steps to Reproduce:
1. g++ -fabi-version=1 templtest.cc
  
Actual results:
fails to compile and prints above errors

Expected results:
success in compiling

Additional info:
also fails on RHEL 4.7 with gcc4-c++-4.1.2-42.EL4 tech preview packages

--- Additional comment from jbastian@redhat.com on 2009-03-13 16:31:05 EDT ---

Created an attachment (id=335155)
demo program

--- Additional comment from jleddy@redhat.com on 2009-03-13 16:40:34 EDT ---

also,

this code works when not called from a class constructor.

struct T
{
    template<size_t N>
    int f(char (&s)[N]) const
    {
        return N;
    }
};

class S
{
    char str[12];
    T t;

public:
    template<class U>
    S(U x)
    {
        printf("%dn", t.f(str));
    }
};

int main()
{
    S s(1);
    T t;

    char q[15];
    t.f(q);
}

yeilds the same error message:

templtest.cc: In constructor ‘S::S(U) [with U = int]’:
templtest.cc:27:   instantiated from here
templtest.cc:21: error: no matching function for call to ‘T::f(char [12])’
templtest.cc:6: note: candidates are: int T::f(char (&)[N]) const [with long
unsigned int N = 12ul]

--- Additional comment from jleddy@redhat.com on 2009-03-16 10:16:48 EDT ---

This shows up in the array dimension checking code:

  /* Check that the dimensions are the same.  */

  if (!cp_tree_equal (TYPE_MIN_VALUE (d1), TYPE_MIN_VALUE (d2)))
    return false;
  max1 = TYPE_MAX_VALUE (d1);
  max2 = TYPE_MAX_VALUE (d2);
  if (processing_template_decl && !abi_version_at_least (2)
      && !value_dependent_expression_p (max1)
      && !value_dependent_expression_p (max2))
    {
      /* With abi-1 we do not fold non-dependent array bounds, (and
	 consequently mangle them incorrectly).  We must therefore
	 fold them here, to verify the domains have the same
	 value.  */
      max1 = fold (max1);
      max2 = fold (max2);
    }

  if (!cp_tree_equal (max1, max2))
    return false;


Here cp_tree_equal fails when using -fabi-version=1 .  The comment about abi-1 is interesting, though I don't know if it has anything to do with it.

The differing values for max1 and max2 is:

(gdb) p t1.common.code
$79 = MINUS_EXPR
(gdb) p t2.common.code
$80 = INTEGER_CST

--- Additional comment from jakub@redhat.com on 2009-03-16 10:27:25 EDT ---

This has been fixed by fix for http://gcc.gnu.org/PR27640 in 4.2 and above and backport of that patch fixes this on 4.1 branch as well.  Except for small comment changes the patched 4.1 instantiate_template is identical to the one in 4.4, so at least in that function no follow-ups were needed.  I haven't tried to fully bootstrap/regtest this patch yet.

--- Additional comment from jakub@redhat.com on 2009-03-16 10:40:09 EDT ---

Created an attachment (id=335355)
gcc41-pr27640.patch

Backported patch.

--- Additional comment from jleddy@redhat.com on 2009-03-17 12:42:39 EDT ---

I've tested and confirmed that the patch does enable compiling w/o error with -fabi-version=1
Comment 2 RHEL Product and Program Management 2009-03-17 13:01:59 EDT
This bugzilla has Keywords: Regression.  

Since no regressions are allowed between releases, 
it is also being proposed as a blocker for this release.  

Please resolve ASAP.
Comment 7 Jeremy West 2010-09-08 11:20:04 EDT
Closing this per discussion with James Leddy who reported this.

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