Patch to expose G++ builtins failures

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Sun Jan 14 05:24:00 GMT 2001


 > From: Mark Mitchell <mark@codesourcery.com>
 > 
 > >>>>> "Kaveh" == Kaveh R Ghazi <ghazi@caip.rutgers.edu> writes:
 > 
 >     Kaveh> This patch of testcases exposes the problems with G++
 >     Kaveh> builtins I mentioned in a previous posting.
 > 
 > Namespace issues is a good guess.  `::abort' isn't *supposed* to be a
 > builtin in the new ABI.  But, probably `::__builtin_strlen' should be.

Agreed, looking in cp/decl.c:builtin_function(), it appears that it
has a special-case for builtins beginning with '_'.

Nevertheless, it (::__builtin_strlen) doesn't work.  And neither does
std::strlen.

I rewrote the testcase attempting to DTRT WRT the namespaces.  I think
I got it right, below is what I came up with.  None of the three uses
of strlen get transformed properly.  They all become a call to
::strlen, which I've replaced with an abort wrapper.

Is what I've appended below something that should work?  If so, I'd
like to install it along with the other testcases similarly updated.

		Thanks,
		--Kaveh


// Test whether this builtin minimally works in G++.
// Origin: Kaveh Ghazi Jan 12, 2001
// Copyright (C) 2001 Free Software Foundation.
//
// Special g++ Options: -O2

namespace std 
{
  extern "C" void abort (void);
  extern "C" __SIZE_TYPE__ strlen (const char *);
}

int main ()
{
  using namespace std;
  
  if (strlen ("hello") != 5)
    abort ();
  if (std::strlen ("hello") != 5)
    abort ();
  if (::__builtin_strlen ("hello") != 5)
    abort ();
  
  return 0;
}

extern "C"
{
  static __SIZE_TYPE__ ::strlen (const char *)
  {
    std::abort ();
  }
}


More information about the Gcc-bugs mailing list