From: "Daniel." <danielhilst@gmail.com>
To: "linux-c-programming@vger.kernel.org"
<linux-c-programming@vger.kernel.org>
Subject: How to check if char pointer is a constant!?
Date: Thu, 7 Jul 2016 16:40:56 -0300 [thread overview]
Message-ID: <CAF3SDA6G32Kub4rK5BSmx7TkWoXnGWW2ESyHnM_+3t-naVPDww@mail.gmail.com> (raw)
Hi everybody,
I have some function, say
void empty(char *p) { p[0] = '\0'; }
If I call it like this empty("Hello") it will segfaults since "Hello"
is put in readonly section of the program. Is there a way to check for
this?! Maybe some nasty gcc extension!?
Regards,
--
"Do or do not. There is no try"
Yoda Master
next reply other threads:[~2016-07-07 19:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-07 19:40 Daniel. [this message]
2016-07-07 20:26 ` How to check if char pointer is a constant!? Phil Sutter
2016-07-08 12:33 ` Daniel.
2016-07-08 12:59 ` Phil Sutter
2016-07-08 14:01 ` Daniel.
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=CAF3SDA6G32Kub4rK5BSmx7TkWoXnGWW2ESyHnM_+3t-naVPDww@mail.gmail.com \
--to=danielhilst@gmail.com \
--cc=linux-c-programming@vger.kernel.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: link
Be 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 NNTP newsgroup(s).