This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/50839] New: Array parameters always take lower precedence than pointer parameters
- From: "classixretrox at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 23 Oct 2011 16:41:46 +0000
- Subject: [Bug c++/50839] New: Array parameters always take lower precedence than pointer parameters
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50839
Bug #: 50839
Summary: Array parameters always take lower precedence than
pointer parameters
Classification: Unclassified
Product: gcc
Version: 4.6.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: classixretrox@gmail.com
Created attachment 25581
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25581
sample1 doesn't compile, whereas sample2 and sample3 do compile.
The title says it all. sample1.cc does not compile, however, sample2.cc and
sample3.cc do. Both were compiled with the -Wall and -std=gnu++0x flags. The
expected output of sample2.cc should be:
array[4] plus variadic
pointer plus variadic
variadic
array[4]
pointer
generic
However, ends up being:
pointer plus variadic
pointer plus variadic
variadic
pointer
pointer
generic
Similarly, sample3.cc ends up being:
variadic
variadic
generic
generic
Instead of:
array[4] plus variadic
variadic
array[4]
generic
The GCC does not see any difference between void f(int[N]) and void f(int*).
If you try to define two functions, it will say that void f(int*) is already
defined, even if you are defining void f(int[N]) instead. You can get around
this with some messy template work (as seem in the second sample), but it
doesn't work as expected.
Using templates, a specialization of int* will always take precedence over a
specialization of int[N]. If I define a variadic function with an int[4] head
and one without a head at all, it will assume the non-specialized version,
which is incorrect (see sample3.cc). If you define a function with an int*
head, it will work, but in that case, you cannot define the function as
constexpr.