public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* odd behavior
@ 2014-08-28 21:20 Michael Williamson
  2014-08-29  5:37 ` Jędrzej Dudkiewicz
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Williamson @ 2014-08-28 21:20 UTC (permalink / raw)
  To: gcc-help

Hi,

Using gcc version 4.6.3 including the parameter -Wall, I discovered
that it gives a warning message for missing closing double quotes
inside sections of code that are not even used due to #if ... #endif
statements. That seems odd.

Just FYI,
-Mike

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: odd behavior
  2014-08-28 21:20 odd behavior Michael Williamson
@ 2014-08-29  5:37 ` Jędrzej Dudkiewicz
  2014-08-29  9:12   ` Jonathan Wakely
  0 siblings, 1 reply; 5+ messages in thread
From: Jędrzej Dudkiewicz @ 2014-08-29  5:37 UTC (permalink / raw)
  To: Michael Williamson; +Cc: gcc-help

I've seen it few times, but was always my fault and section was in
fact compiled. Try preprocessing your input file using -E option and
check if it really isn't used.

On Thu, Aug 28, 2014 at 11:20 PM, Michael Williamson
<michael.h.williamson@gmail.com> wrote:
> Hi,
>
> Using gcc version 4.6.3 including the parameter -Wall, I discovered
> that it gives a warning message for missing closing double quotes
> inside sections of code that are not even used due to #if ... #endif
> statements. That seems odd.
>
> Just FYI,
> -Mike



-- 
Jędrzej Dudkiewicz

I really hate this damn machine, I wish that they would sell it.
It never does just what I want, but only what I tell it.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: odd behavior
  2014-08-29  5:37 ` Jędrzej Dudkiewicz
@ 2014-08-29  9:12   ` Jonathan Wakely
  2014-08-29 10:36     ` Jędrzej Dudkiewicz
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Wakely @ 2014-08-29  9:12 UTC (permalink / raw)
  To: Jędrzej Dudkiewicz; +Cc: Michael Williamson, gcc-help

On 29 August 2014 06:37, Jędrzej Dudkiewicz wrote:
> I've seen it few times, but was always my fault and section was in
> fact compiled. Try preprocessing your input file using -E option and
> check if it really isn't used.

No, it definitely happens in code that isn't compiled, try it:

#if 0
const char* s = ";
#endif
int main() { }

x.c:2:17: warning: missing terminating " character [enabled by default]
 const char* s = ";
                 ^

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: odd behavior
  2014-08-29  9:12   ` Jonathan Wakely
@ 2014-08-29 10:36     ` Jędrzej Dudkiewicz
  2014-08-29 12:12       ` Segher Boessenkool
  0 siblings, 1 reply; 5+ messages in thread
From: Jędrzej Dudkiewicz @ 2014-08-29 10:36 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: Michael Williamson, gcc-help

Ah-ha! You're right. Now I see that this warning is issued by
preprocessor, not by compiler. Now that I think about it, it seems
logical. Preprocessor has to tokenize input to perform substitutions
and such, so even if code isn't meant for compiler, it must follow
some rules - ifdefined parts of code are not comments. Is that right?

On Fri, Aug 29, 2014 at 11:11 AM, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> On 29 August 2014 06:37, Jędrzej Dudkiewicz wrote:
>> I've seen it few times, but was always my fault and section was in
>> fact compiled. Try preprocessing your input file using -E option and
>> check if it really isn't used.
>
> No, it definitely happens in code that isn't compiled, try it:
>
> #if 0
> const char* s = ";
> #endif
> int main() { }
>
> x.c:2:17: warning: missing terminating " character [enabled by default]
>  const char* s = ";
>                  ^



-- 
Jędrzej Dudkiewicz

I really hate this damn machine, I wish that they would sell it.
It never does just what I want, but only what I tell it.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: odd behavior
  2014-08-29 10:36     ` Jędrzej Dudkiewicz
@ 2014-08-29 12:12       ` Segher Boessenkool
  0 siblings, 0 replies; 5+ messages in thread
From: Segher Boessenkool @ 2014-08-29 12:12 UTC (permalink / raw)
  To: Jędrzej Dudkiewicz; +Cc: Jonathan Wakely, Michael Williamson, gcc-help

[Please don't top-post.  Thanks.]

> > #if 0
> > const char* s = ";
> > #endif
> > int main() { }

> Ah-ha! You're right. Now I see that this warning is issued by
> preprocessor, not by compiler. Now that I think about it, it seems
> logical. Preprocessor has to tokenize input to perform substitutions
> and such, so even if code isn't meant for compiler, it must follow
> some rules - ifdefined parts of code are not comments. Is that right?

C11 6.4/3 says the lonely quote is undefined behaviour.  Your program
might or might not work (the same) with a different (version of the)
compiler.  So a warning is good.


Segher

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-08-29 12:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-28 21:20 odd behavior Michael Williamson
2014-08-29  5:37 ` Jędrzej Dudkiewicz
2014-08-29  9:12   ` Jonathan Wakely
2014-08-29 10:36     ` Jędrzej Dudkiewicz
2014-08-29 12:12       ` Segher Boessenkool

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).