public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/28262] New: Inconsistent "default arguments are only permitted for function parameters".
@ 2006-07-05 0:20 jason dot cipriani at gmail dot com
2006-07-05 0:22 ` [Bug c++/28262] " jason dot cipriani at gmail dot com
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: jason dot cipriani at gmail dot com @ 2006-07-05 0:20 UTC (permalink / raw)
To: gcc-bugs
Description:
g++ appears to have issues when declaring function pointer types that accept
default function parameters. However it does not have issues when declaring
non-pointer function types that accept default function parameters. For
example, the following code:
typedef void (* funcptr) (int = 10);
Produces the error "default arguments are only permitted for function
parameters". However, a "workaround" for this exists. The following code
compiles without problems, and the default parameter works:
typedef void (funcptrhack) (int = 10);
typedef funcptrhack * funcptr;
I believe this is a bug because a workaround exists, and because of the
inconsistency. Additionally, this problem does not seem to occur on pre-3.4.2
versions of GCC (the next lowest version tested was 3.3.3; not sure where in
that range it started failing). However, I am not sure what the bug is: I
believe that either both of the above examples should succeed or both should
fail.
"Buggy" behavior observed on versions:
3.4.2 [g++.exe (GCC) 3.4.2 (mingw-special)]
3.4.3 [specific version unavailable]
3.4.4 [specific version unavailable]
3.4.4 [g++ (GCC) 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125)]
3.4.5 [g++ (GCC) 3.4.5 (Gentoo 3.4.5, ssp-3.4.5-1.0, pie-8.7.9)]
4.0.3 [Ubuntu 4.0.3-1ubuntu5]
"Working" behavior observed on versions:
3.2 [g++ (GCC) 3.2 20020903 (Red Hat Linux 8.0 3.2-7)]
3.2.2 [specific version unavailable]
3.3.3 [specific version unavailable]
Configuration options unavailable. Some system types and GCC versions
unavailable as indicated above.
Preprocessed output for both cases follows:
---
"Buggy" output, compiled with:
g++ -W -Wall -pedantic
Preprocessed file:
# 1 "gccbug.cpp"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "gccbug.cpp"
typedef void (* funcptr) (int = 10);
void testfunc (int) {
}
int main (int, char **) {
funcptr fp = &testfunc;
(*fp)();
(*fp)(20);
return 0;
}
---
"Working" output, compiled with:
g++ -W -Wall -pedantic
Preprocessed file:
# 1 "gccbug.cpp"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "gccbug.cpp"
typedef void (funcptrhack) (int = 10);
typedef funcptrhack * funcptr;
void testfunc (int) {
}
int main (int, char **) {
funcptr fp = &testfunc;
(*fp)();
(*fp)(20);
return 0;
}
---
-Jason
--
Summary: Inconsistent "default arguments are only permitted for
function parameters".
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jason dot cipriani at gmail dot com
GCC build triplet: Multiple, see report.
GCC host triplet: Multiple, see report.
GCC target triplet: Multiple, see report.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28262
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/28262] Inconsistent "default arguments are only permitted for function parameters".
2006-07-05 0:20 [Bug c++/28262] New: Inconsistent "default arguments are only permitted for function parameters" jason dot cipriani at gmail dot com
2006-07-05 0:22 ` [Bug c++/28262] " jason dot cipriani at gmail dot com
@ 2006-07-05 0:22 ` jason dot cipriani at gmail dot com
2006-07-05 0:24 ` jason dot cipriani at gmail dot com
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jason dot cipriani at gmail dot com @ 2006-07-05 0:22 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from jason dot cipriani at gmail dot com 2006-07-05 00:22 -------
Created an attachment (id=11821)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11821&action=view)
"Working" preprocessed source.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28262
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/28262] Inconsistent "default arguments are only permitted for function parameters".
2006-07-05 0:20 [Bug c++/28262] New: Inconsistent "default arguments are only permitted for function parameters" jason dot cipriani at gmail dot com
@ 2006-07-05 0:22 ` jason dot cipriani at gmail dot com
2006-07-05 0:22 ` jason dot cipriani at gmail dot com
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jason dot cipriani at gmail dot com @ 2006-07-05 0:22 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from jason dot cipriani at gmail dot com 2006-07-05 00:22 -------
Created an attachment (id=11820)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11820&action=view)
"Broken" preprocessed source.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28262
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/28262] Inconsistent "default arguments are only permitted for function parameters".
2006-07-05 0:20 [Bug c++/28262] New: Inconsistent "default arguments are only permitted for function parameters" jason dot cipriani at gmail dot com
2006-07-05 0:22 ` [Bug c++/28262] " jason dot cipriani at gmail dot com
2006-07-05 0:22 ` jason dot cipriani at gmail dot com
@ 2006-07-05 0:24 ` jason dot cipriani at gmail dot com
2006-07-05 0:31 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jason dot cipriani at gmail dot com @ 2006-07-05 0:24 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from jason dot cipriani at gmail dot com 2006-07-05 00:23 -------
Apologies for inlining preprocessor output. I have attached the files.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28262
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/28262] Inconsistent "default arguments are only permitted for function parameters".
2006-07-05 0:20 [Bug c++/28262] New: Inconsistent "default arguments are only permitted for function parameters" jason dot cipriani at gmail dot com
` (2 preceding siblings ...)
2006-07-05 0:24 ` jason dot cipriani at gmail dot com
@ 2006-07-05 0:31 ` pinskia at gcc dot gnu dot org
2006-07-05 0:35 ` jason dot cipriani at gmail dot com
2006-07-05 0:41 ` pinskia at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-07-05 0:31 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from pinskia at gcc dot gnu dot org 2006-07-05 00:31 -------
Your workaround is really invalid code and should be rejected.
So what we have here is an accepts invalid that is not a regression.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
GCC build triplet|Multiple, see report. |
GCC host triplet|Multiple, see report. |
GCC target triplet|Multiple, see report. |
Keywords| |accepts-invalid
Known to fail| |2.95.3 4.0.0 4.1.0 4.2.0
| |3.0.4 3.2.3 3.3.3 3.4.0
Last reconfirmed|0000-00-00 00:00:00 |2006-07-05 00:31:16
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28262
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/28262] Inconsistent "default arguments are only permitted for function parameters".
2006-07-05 0:20 [Bug c++/28262] New: Inconsistent "default arguments are only permitted for function parameters" jason dot cipriani at gmail dot com
` (3 preceding siblings ...)
2006-07-05 0:31 ` pinskia at gcc dot gnu dot org
@ 2006-07-05 0:35 ` jason dot cipriani at gmail dot com
2006-07-05 0:41 ` pinskia at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: jason dot cipriani at gmail dot com @ 2006-07-05 0:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from jason dot cipriani at gmail dot com 2006-07-05 00:35 -------
Agreed. Wasn't sure if it was actually supposed to work or not.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28262
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/28262] Inconsistent "default arguments are only permitted for function parameters".
2006-07-05 0:20 [Bug c++/28262] New: Inconsistent "default arguments are only permitted for function parameters" jason dot cipriani at gmail dot com
` (4 preceding siblings ...)
2006-07-05 0:35 ` jason dot cipriani at gmail dot com
@ 2006-07-05 0:41 ` pinskia at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-07-05 0:41 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from pinskia at gcc dot gnu dot org 2006-07-05 00:41 -------
Just a note, the follow patch deprecated them in 3.4:
http://gcc.gnu.org/ml/gcc-patches/2003-07/msg02485.html
Though it seems to miss this part for some reason.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28262
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2006-07-05 0:41 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-05 0:20 [Bug c++/28262] New: Inconsistent "default arguments are only permitted for function parameters" jason dot cipriani at gmail dot com
2006-07-05 0:22 ` [Bug c++/28262] " jason dot cipriani at gmail dot com
2006-07-05 0:22 ` jason dot cipriani at gmail dot com
2006-07-05 0:24 ` jason dot cipriani at gmail dot com
2006-07-05 0:31 ` pinskia at gcc dot gnu dot org
2006-07-05 0:35 ` jason dot cipriani at gmail dot com
2006-07-05 0:41 ` 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).