This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/24663] New: Template instantiation generating a zero-sized array doesn't fail


The following compliant code fails to compile:

  template<int I> int f1 (char[I]);
  template<int I> int f1 (char p1 = I);
  int i = f1<0>(0);

.. instead it generates an error, e.g.:

  test.C:3: error: call of overloaded 'f1(int)' is ambiguous
  test.C:1: note: candidates are: int f1(char*) [with int I = 0]
  test.C:2: note:                 int f1(char) [with int I = 0]

The first template should fail to match (SFINAE) because doing so would cause a
reference to a zero-sized array (as per ISO C++ section 14.8.2.2).

It is possible that gcc may be performing the "type[size] --> type *"
conversion too early, as prohibited by 14.8.2.3:

  After this substitution is performed, the function parameter type
  adjustments described in 8.3.5 are performed. [Example: A parameter
  type of ?void ()(const int, int[5])? becomes ?void(*)(int,int*)?.


-- 
           Summary: Template instantiation generating a zero-sized array
                    doesn't fail
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jconner at apple dot com


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]