public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/26110]  New: using directive breaks ADL
@ 2006-02-05 22:15 dg001 at t-online dot de
  2006-02-05 22:22 ` [Bug c++/26110] " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: dg001 at t-online dot de @ 2006-02-05 22:15 UTC (permalink / raw)
  To: gcc-bugs

When compiling the following code, an incorrect binary is produced:

--- BEGIN CODE ---
namespace test {
        double f(double f)
        {
                return f + 1.;
        }
}

double f(float d)
{
        return d;
}

int main(int argc, char *argv[]) 
{
        using test::f;

        float d = 2.;

        double result1 = f(d);

        double result2 = test::f(d);

        return 0;
}       

--- END CODE ---
The line
double result1 = f(d);
should call the function "double f(float d)", instead it calls the function
"double f(double f)" in namespace test.
This breaks argument dependent lookup. The using directive should only make
visible the function in namespace test, but not hide the global one.
If you replace "using test::f" with "using namespace test", then everything
works correctly.


gcc -v gives me:

~> gcc -v
Using built-in specs.
Target: x86_64-suse-linux
Configured with: ../configure --enable-threads=posix --prefix=/usr
--with-local-prefix=/usr/local --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64
--enable-languages=c,c++,objc,f95,java,ada --disable-checking
--with-gxx-include-dir=/usr/include/c++/4.0.2 --enable-java-awt=gtk
--disable-libjava-multilib --with-slibdir=/lib64 --with-system-zlib
--enable-shared --enable-__cxa_atexit --without-system-libunwind
--host=x86_64-suse-linux
Thread model: posix
gcc version 4.0.2 20050901 (prerelease) (SUSE Linux)


-- 
           Summary: using directive breaks ADL
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dg001 at t-online dot de


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


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

end of thread, other threads:[~2006-02-06 20:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-05 22:15 [Bug c++/26110] New: using directive breaks ADL dg001 at t-online dot de
2006-02-05 22:22 ` [Bug c++/26110] " pinskia at gcc dot gnu dot org
2006-02-05 23:14 ` dg001 at t-online dot de
2006-02-05 23:41 ` pinskia at gcc dot gnu dot org
2006-02-06  0:17 ` dg001 at t-online dot de
2006-02-06  0:29 ` pinskia at gcc dot gnu dot org
2006-02-06 20:06 ` dg001 at t-online dot de
2006-02-06 20:24 ` 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).