public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: Martin Kahlert <martin.kahlert@infineon.com> To: gcc-bugs@gcc.gnu.org Subject: Is this a bug? Date: Wed, 06 Dec 2000 03:42:00 -0000 [thread overview] Message-ID: <20001206124239.A20108@keksy.muc.infineon.com> (raw) Hi! I have code similar to this: #include <stdio.h> #include <stdlib.h> #include <string.h> void f(const char **x) { while(*x) { puts(*x); x++; } } int main(int argc,char *argv[]) { char **buffer; buffer = calloc(3, sizeof(char*)); buffer[0] = strdup("Hello"); buffer[1] = strdup("World"); f(buffer); return 0; } gcc -Wall -o prog prog.c gives: t.c: In function `main': t.c:23: warning: passing arg 1 of `f' from incompatible pointer type (the warning comes from the missing const) Is this a bug? At least it is an inconsistency: f(const char *buffer) { puts(buffer); } int main() { char b[] = "Hello World"; f(b); return 0; } works without any warning! Thanks for any clarification, Martin. -- The early bird gets the worm. If you want something else for breakfast, get up later. >From jsm28@cam.ac.uk Wed Dec 06 03:55:00 2000 From: "Joseph S. Myers" <jsm28@cam.ac.uk> To: Martin Kahlert <martin.kahlert@infineon.com> Cc: <gcc-bugs@gcc.gnu.org> Subject: Re: Is this a bug? Date: Wed, 06 Dec 2000 03:55:00 -0000 Message-id: <Pine.LNX.4.30.0012061150200.31115-100000@kern.srcf.societies.cam.ac.uk> References: <20001206124239.A20108@keksy.muc.infineon.com> X-SW-Source: 2000-12/msg00131.html Content-length: 531 On Wed, 6 Dec 2000, Martin Kahlert wrote: > t.c: In function `main': > t.c:23: warning: passing arg 1 of `f' from incompatible pointer type > (the warning comes from the missing const) > Is this a bug? No; you can pass a "char **" to a function expecting a "char **" or a "char *const *", but not to one expecting a "const char **" or a "const char *const *". It's only at the first level of indirection that you can have different type qualifiers in the expected type and the type passed. -- Joseph S. Myers jsm28@cam.ac.uk
next reply other threads:[~2000-12-06 3:42 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2000-12-06 3:42 Martin Kahlert [this message] -- strict thread matches above, loose matches on Subject: below -- 2003-08-21 9:23 Lev Assinovsky 2003-02-06 21:33 Matthew Toseland 2003-02-06 22:18 ` Falk Hueffner 2003-01-02 21:21 Songtao Chen 2003-01-02 21:24 ` Neil Booth 2003-01-02 21:42 ` Songtao Chen 2003-01-02 21:46 ` Neil Booth 2003-01-02 23:00 ` Songtao Chen 2003-01-13 5:17 ` Zack Weinberg 2003-01-13 5:17 ` Songtao Chen 2002-08-30 2:41 Ritzert 2002-09-03 14:07 ` Matt Austern 2002-09-10 1:06 ` Michael Ritzert 2000-01-30 16:44 Kuo Yu Chuang [not found] <007d01bf6988$d2fb0c40$795d608c@ccl.itri.org.tw> 2000-01-30 2:45 ` Martin v. Loewis 1999-05-11 21:09 Christian II 1999-05-11 23:44 ` Martin v. Loewis
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20001206124239.A20108@keksy.muc.infineon.com \ --to=martin.kahlert@infineon.com \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).