Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #400934 > unrolled thread

Public Service Announcement: Please use /GF with Visual Studio when you want to collapse constant strings!

Started byJohann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid>
First post2026-08-09 05:39 +0800
Last post2026-08-11 20:16 +0100
Articles 17 — 12 participants

Back to article view | Back to comp.lang.c


Contents

  Public Service Announcement: Please use /GF with Visual Studio when you want to collapse constant strings! Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-08-09 05:39 +0800
    Re: Public Service Announcement: Please use /GF with Visual Studio when you want to collapse constant strings! legalize+jeeves@mail.xmission.com (Richard) - 2026-08-10 15:51 +0000
      Re: Public Service Announcement: Please use /GF with Visual Studio when you want to collapse constant strings! Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-08-10 15:33 -0700
        Re: Public Service Announcement: Please use /GF with Visual Studio when you want to collapse constant strings! R Kym Horsell <kym@sdf.org> - 2026-08-11 04:02 +0000
          Re: Public Service Announcement: Please use /GF with Visual Studio when you want to collapse constant strings! David Brown <david.brown@hesbynett.no> - 2026-08-11 08:34 +0200
            Re: Public Service Announcement: Please use /GF with Visual Studio when you want to collapse constant strings! Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-08-11 00:12 -0700
              Re: Public Service Announcement: Please use /GF with Visual Studio when you want to collapse constant strings! cross@spitfire.i.gajendra.net (Dan Cross) - 2026-08-11 13:50 +0000
            Re: Public Service Announcement: Please use /GF with Visual Studio when you want to collapse constant strings! Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-08-11 16:32 +0200
              Re: Public Service Announcement: Please use /GF with Visual Studio when you want to collapse constant strings! Anton Antimo <anton@safunu.org> - 2026-08-11 13:24 -0300
            Re: Public Service Announcement: Please use /GF with Visual Studio when you want to collapse constant strings! Charlie Gibbs <cgibbs@kltpzyxm.invalid> - 2026-08-11 17:13 +0000
          Re: Public Service Announcement: Please use /GF with Visual Studio when you want to collapse constant strings! legalize+jeeves@mail.xmission.com (Richard) - 2026-08-11 15:10 +0000
            Re: Public Service Announcement: Please use /GF with Visual Studio when you want to collapse constant strings! "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2026-08-11 14:30 -0700
              Re: Public Service Announcement: Please use /GF with Visual Studio when you want to collapse constant strings! legalize+jeeves@mail.xmission.com (Richard) - 2026-08-13 14:09 +0000
                Re: Public Service Announcement: Please use /GF with Visual Studio when you want to collapse constant strings! "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2026-08-13 14:39 -0700
                  Re: Public Service Announcement: Please use /GF with Visual Studio when you want to collapse constant strings! "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2026-08-13 14:41 -0700
    Re: Public Service Announcement: Please use /GF with Visual Studio when you want to collapse constant strings! Bonita Montero <Bonita.Montero@gmail.com> - 2026-08-11 19:17 +0200
      Re: Public Service Announcement: Please use /GF with Visual Studio when you want to collapse constant strings! Richard Harnden <richard.nospam@gmail.invalid> - 2026-08-11 20:16 +0100

#400934 — Public Service Announcement: Please use /GF with Visual Studio when you want to collapse constant strings!

FromJohann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid>
Date2026-08-09 05:39 +0800
SubjectPublic Service Announcement: Please use /GF with Visual Studio when you want to collapse constant strings!
Message-ID<smNdS.557$7WX8.434@fx08.ams4>
Dear comp.lang.c, comp.os.ms-windows.programmer.win32,

and perhaps other groups that may make use of this information, but I
don't know about.

When you want to use == to compare strings such as "a", with "b" because
all your strings are constants, please remember to add /GF to your
CL.EXE command line.  I have no idea how to do this in the IDE, but I'm
sure you'll figure it out if you really have to.

This kind of programming happens in small student projects, so be mind-
ful of also telling your students about this, in the classroom.


Best wishes, and happy string comparison with ==.
-- 
Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
I'm not from the Internet, I just work there. | via Easynews.com
https://bsky.app/profile/myrkraverk.bsky.social | for ( ;; ) _:;

[toc] | [next] | [standalone]


#400947

Fromlegalize+jeeves@mail.xmission.com (Richard)
Date2026-08-10 15:51 +0000
Message-ID<115cs1r$1q2i3$1@news.xmission.com>
In reply to#400934
From the documentation:

	"/GF is in effect when /O1 or /O2 is used."

So... unless you are distributing debug executables, you're already
getting this with typical release configurations.
-- 
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
            The Terminals Wiki <http://terminals-wiki.org>
     The Computer Graphics Museum <http://computergraphicsmuseum.org>
  Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>

[toc] | [prev] | [next] | [standalone]


#400953

FromKeith Thompson <Keith.S.Thompson+u@gmail.com>
Date2026-08-10 15:33 -0700
Message-ID<115djjf$3g75j$2@kst.eternal-september.org>
In reply to#400947
legalize+jeeves@mail.xmission.com (Richard) writes:
> From the documentation:
>
> 	"/GF is in effect when /O1 or /O2 is used."
>
> So... unless you are distributing debug executables, you're already
> getting this with typical release configurations.

The "announcement" was posted by "Johann", who is in my killfile,
so I didn't see it.  I knew he was an arrogant troll, but I didn't
know that he posts deliberate misinformation aimed at inexperienced
C programmers.

The troll's claim was that it's a good idea to use "/GF" in Visual
Studio if you want to compare strings with "==".

This is, of course, a remarkably bad idea (and a common error by
inexperienced C programmers).  C strings, whether literals or not,
should be compared using strcmp() or something similar.  The "=="
operator will compare their addresses.

The "/GF" option causes Visual Studio to share storage for identical
string literals.  It has no effect on strings other than string
literals, so for example `s == "foo"` is still likely to fail.
If you're writing code whose behavior depends on "/GF", you're
almost certainly doing something wrong.

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */

[toc] | [prev] | [next] | [standalone]


#400961

FromR Kym Horsell <kym@sdf.org>
Date2026-08-11 04:02 +0000
Message-ID<115e6ta$120f$2@nnrp.usenet.blueworldhosting.com>
In reply to#400953
In comp.lang.c Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
> legalize+jeeves@mail.xmission.com (Richard) writes:
>> From the documentation:
>>
>>       "/GF is in effect when /O1 or /O2 is used."
>>
>> So... unless you are distributing debug executables, you're already
>> getting this with typical release configurations.
> 
> The "announcement" was posted by "Johann", who is in my killfile,
> so I didn't see it.  I knew he was an arrogant troll, but I didn't
> know that he posts deliberate misinformation aimed at inexperienced
> C programmers.
> 
> The troll's claim was that it's a good idea to use "/GF" in Visual
> Studio if you want to compare strings with "==".
> 
> This is, of course, a remarkably bad idea (and a common error by
> inexperienced C programmers).  C strings, whether literals or not,
> should be compared using strcmp() or something similar.  The "=="
> operator will compare their addresses.
> 
> The "/GF" option causes Visual Studio to share storage for identical
> string literals.  It has no effect on strings other than string
> literals, so for example `s == "foo"` is still likely to fail.
> If you're writing code whose behavior depends on "/GF", you're
> almost certainly doing something wrong.

Kinda had a feel it was straight out of chatGPT or similar.

-- 
The next big move in software houses is firing all the engineers
that cut code and hiring people to debug AI-generated code.

Grindr CEO says AI is doing^h^h^hcreating work that would have required 
hiring 200 additional engineers
Yahoo Finance, 8 Aug 2026 02:11
Grindr CEO George Arison said that AI had increased its engineering output
2.5-fold.

[toc] | [prev] | [next] | [standalone]


#400964

FromDavid Brown <david.brown@hesbynett.no>
Date2026-08-11 08:34 +0200
Message-ID<115efpb$3o7ie$1@dont-email.me>
In reply to#400961
On 11/08/2026 06:02, R Kym Horsell wrote:
> In comp.lang.c Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>> legalize+jeeves@mail.xmission.com (Richard) writes:
>>>  From the documentation:
>>>
>>>        "/GF is in effect when /O1 or /O2 is used."
>>>
>>> So... unless you are distributing debug executables, you're already
>>> getting this with typical release configurations.
>>
>> The "announcement" was posted by "Johann", who is in my killfile,
>> so I didn't see it.  I knew he was an arrogant troll, but I didn't
>> know that he posts deliberate misinformation aimed at inexperienced
>> C programmers.
>>
>> The troll's claim was that it's a good idea to use "/GF" in Visual
>> Studio if you want to compare strings with "==".
>>
>> This is, of course, a remarkably bad idea (and a common error by
>> inexperienced C programmers).  C strings, whether literals or not,
>> should be compared using strcmp() or something similar.  The "=="
>> operator will compare their addresses.
>>
>> The "/GF" option causes Visual Studio to share storage for identical
>> string literals.  It has no effect on strings other than string
>> literals, so for example `s == "foo"` is still likely to fail.
>> If you're writing code whose behavior depends on "/GF", you're
>> almost certainly doing something wrong.
> 
> Kinda had a feel it was straight out of chatGPT or similar.
> 

I doubt it.  AI's regularly make silly mistakes and hallucinate things, 
but in cases like this where the mistake turns up regularly in Stack 
Overflow and the like, I would not expect to see an AI get it wrong. 
AI's are quite good at summarising information from existing sources - 
it's when they are interpolating or extrapolating that they come up with 
bizarre things.  So IMHO the post suggesting that comparing C strings 
with "==" is sometimes a good idea is human-generated - either someone 
who knows genuinely misunderstands the C language, or someone who is 
trolling.

Of course, it is still possible that he used AI while posting.  An AI is 
unlikely to suggest using "==" to compare strings in C, but it could get 
mixed up with other languages like C++ std::string comparison.  And AI's 
tend to be sycophantic when asked for confirmation, so if you ask "Is it 
a good idea to use /GF when comparing strings with ==", then it can 
re-enforce a bad idea.


In this poster's case, I am not sure.  His posting style is highly 
anti-social and shows he does not read other people's posts and gives 
others no consideration at all - his posts are purely ego-centric.  But 
he has also demonstrated that despite apparent long experience as a 
programmer, he misunderstands C in many aspects.  He seems to base his 
programming knowledge on a "this worked for me" basis, rather than any 
kind of objective information.  And since he has done this for a long 
time, he things he knows it all - he thinks his personal experience 
makes him an expert in the language and thus qualified to give advice to 
others and to sneer at people who /actually/ understand the language and 
how it works.

This all makes him highly irritating to people who have put a lot of 
time and effort into understanding the language, and into helping others 
understand it (such as Keith).  It makes him particularly dangerous to 
relative beginners who might mistake his misplaced self-confidence for 
authority, and believe what he writes.



[toc] | [prev] | [next] | [standalone]


#400967

FromKeith Thompson <Keith.S.Thompson+u@gmail.com>
Date2026-08-11 00:12 -0700
Message-ID<115ei17$3oq17$1@kst.eternal-september.org>
In reply to#400964
David Brown <david.brown@hesbynett.no> writes:
> On 11/08/2026 06:02, R Kym Horsell wrote:
>> In comp.lang.c Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>>> legalize+jeeves@mail.xmission.com (Richard) writes:
>>>>  From the documentation:
>>>>
>>>>        "/GF is in effect when /O1 or /O2 is used."
>>>>
>>>> So... unless you are distributing debug executables, you're already
>>>> getting this with typical release configurations.
>>>
>>> The "announcement" was posted by "Johann", who is in my killfile,
>>> so I didn't see it.  I knew he was an arrogant troll, but I didn't
>>> know that he posts deliberate misinformation aimed at inexperienced
>>> C programmers.
>>>
>>> The troll's claim was that it's a good idea to use "/GF" in Visual
>>> Studio if you want to compare strings with "==".
>>>
>>> This is, of course, a remarkably bad idea (and a common error by
>>> inexperienced C programmers).  C strings, whether literals or not,
>>> should be compared using strcmp() or something similar.  The "=="
>>> operator will compare their addresses.
>>>
>>> The "/GF" option causes Visual Studio to share storage for identical
>>> string literals.  It has no effect on strings other than string
>>> literals, so for example `s == "foo"` is still likely to fail.
>>> If you're writing code whose behavior depends on "/GF", you're
>>> almost certainly doing something wrong.
>> Kinda had a feel it was straight out of chatGPT or similar.
>
> I doubt it.
[snip]

I suggest that it doesn't matter, and that we shouldn't waste time
speculating about it.

"Johann" is either an arrogant troll or a computer simulation of
an arrogant troll.  Either the person posting or the person running
the bot likely craves attention.  Let's not provide it.

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */

[toc] | [prev] | [next] | [standalone]


#400981

Fromcross@spitfire.i.gajendra.net (Dan Cross)
Date2026-08-11 13:50 +0000
Message-ID<115f9aj$j2l$1@reader1.panix.com>
In reply to#400967
In article <115ei17$3oq17$1@kst.eternal-september.org>,
Keith Thompson  <Keith.S.Thompson+u@gmail.com> wrote:
>David Brown <david.brown@hesbynett.no> writes:
>> [snip]
>> I doubt it.
>[snip]
>
>I suggest that it doesn't matter, and that we shouldn't waste time
>speculating about it.
>
>"Johann" is either an arrogant troll or a computer simulation of
>an arrogant troll.  Either the person posting or the person running
>the bot likely craves attention.  Let's not provide it.

Agreed.  Please don't feed the troll.

	- Dan C.

[toc] | [prev] | [next] | [standalone]


#400986

FromJanis Papanagnou <janis_papanagnou+ng@hotmail.com>
Date2026-08-11 16:32 +0200
Message-ID<115fbq7$3f3uu$1@dont-email.me>
In reply to#400964
On 2026-08-11 08:34, David Brown wrote:
>> [...]
> 
> I doubt it.  AI's regularly make silly mistakes and hallucinate things, 
> but in cases like this where the mistake turns up regularly in Stack 
> Overflow and the like, I would not expect to see an AI get it wrong. 

> AI's are quite good at summarising information from existing sources - 
> it's when they are interpolating or extrapolating that they come up with 
> bizarre things. [...]

Yes, but the inherent problem with that is that this distinction is
not necessarily decidable, identifiable or visible. Unless "obvious"
you'd need own expertise or a second reliable information channel at
least to be sure. And with a reliable channel, why using AI in the
first place. I think use of AI is just convenience; a fast and single
point of access for all topics. Though some folks really "trust" in
AI. :-/

Janis

[toc] | [prev] | [next] | [standalone]


#401006

FromAnton Antimo <anton@safunu.org>
Date2026-08-11 13:24 -0300
Message-ID<87v79g4ock.fsf@safunu.org>
In reply to#400986
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

> On 2026-08-11 08:34, David Brown wrote:
>>> [...]
>> I doubt it.  AI's regularly make silly mistakes and hallucinate
>> things, but in cases like this where the mistake turns up regularly
>> in Stack Overflow and the like, I would not expect to see an AI get
>> it wrong. 
>
>> AI's are quite good at summarising information from existing sources
>> - it's when they are interpolating or extrapolating that they come
>> up with bizarre things. [...]
>
> Yes, but the inherent problem with that is that this distinction is
> not necessarily decidable, identifiable or visible. Unless "obvious"
> you'd need own expertise or a second reliable information channel at
> least to be sure. And with a reliable channel, why using AI in the
> first place. I think use of AI is just convenience; a fast and single
> point of access for all topics. Though some folks really "trust" in
> AI. :-/

Indeed---fast, single point of access for all topics.  Very useful when
setting up your personal tools, for example.  Why bother the local gurus
when a machine can get us up to speed, hopefully letting us talk to the
the community more interesting subjects?  (Of course, there's always the
unwise way of using everything.)

[toc] | [prev] | [next] | [standalone]


#401011

FromCharlie Gibbs <cgibbs@kltpzyxm.invalid>
Date2026-08-11 17:13 +0000
Message-ID<HKIeS.3232$4QJ.265@fx21.iad>
In reply to#400964
On 2026-08-11, David Brown <david.brown@hesbynett.no> wrote:

> This all makes him highly irritating to people who have put a lot of 
> time and effort into understanding the language, and into helping others 
> understand it (such as Keith).  It makes him particularly dangerous to 
> relative beginners who might mistake his misplaced self-confidence for 
> authority, and believe what he writes.

"People who think they know everything annoy those of us who do."  :-)

-- 
/~\  Charlie Gibbs                  |  In this world there are
\ /  <cgibbs@kltpzyxm.invalid>      |  two kinds of people:
 X   I'm really at ac.dekanfrus     |  1. Those who can extrapolate
/ \  if you read it the right way.  |  from incomplete data.

[toc] | [prev] | [next] | [standalone]


#400992

Fromlegalize+jeeves@mail.xmission.com (Richard)
Date2026-08-11 15:10 +0000
Message-ID<115fe0l$1ukk3$2@news.xmission.com>
In reply to#400961
kymhorsell@gmail.com spake the secret code
<115e6ta$120f$2@nnrp.usenet.blueworldhosting.com> thusly:

>In comp.lang.c Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>> The troll's claim was that it's a good idea to use "/GF" in Visual
>> Studio if you want to compare strings with "==".
>> 
>> This is, of course, a remarkably bad idea (and a common error by
>> inexperienced C programmers).  C strings, whether literals or not,
>> should be compared using strcmp() or something similar.  The "=="
>> operator will compare their addresses.
>
>Kinda had a feel it was straight out of chatGPT or similar.

ChatGPT isn't that stupid and is more likely to alert you that you are
doing a meaningless address compare than an actual string compare.
-- 
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
            The Terminals Wiki <http://terminals-wiki.org>
     The Computer Graphics Museum <http://computergraphicsmuseum.org>
  Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>

[toc] | [prev] | [next] | [standalone]


#401031

From"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>
Date2026-08-11 14:30 -0700
Message-ID<115g4af$b6pj$1@dont-email.me>
In reply to#400992
On 8/11/2026 8:10 AM, Richard wrote:
> kymhorsell@gmail.com spake the secret code
> <115e6ta$120f$2@nnrp.usenet.blueworldhosting.com> thusly:
> 
>> In comp.lang.c Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>>> The troll's claim was that it's a good idea to use "/GF" in Visual
>>> Studio if you want to compare strings with "==".
>>>
>>> This is, of course, a remarkably bad idea (and a common error by
>>> inexperienced C programmers).  C strings, whether literals or not,
>>> should be compared using strcmp() or something similar.  The "=="
>>> operator will compare their addresses.
>>
>> Kinda had a feel it was straight out of chatGPT or similar.
> 
> ChatGPT isn't that stupid and is more likely to alert you that you are
> doing a meaningless address compare than an actual string compare.

Hopefully...

[toc] | [prev] | [next] | [standalone]


#401108

Fromlegalize+jeeves@mail.xmission.com (Richard)
Date2026-08-13 14:09 +0000
Message-ID<115kj6g$27ktp$3@news.xmission.com>
In reply to#401031
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> spake the secret code
<115g4af$b6pj$1@dont-email.me> thusly:

>On 8/11/2026 8:10 AM, Richard wrote:
>> kymhorsell@gmail.com spake the secret code
>> <115e6ta$120f$2@nnrp.usenet.blueworldhosting.com> thusly:
>> 
>>> In comp.lang.c Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>>>> The troll's claim was that it's a good idea to use "/GF" in Visual
>>>> Studio if you want to compare strings with "==".
>>>>
>>>> This is, of course, a remarkably bad idea (and a common error by
>>>> inexperienced C programmers).  C strings, whether literals or not,
>>>> should be compared using strcmp() or something similar.  The "=="
>>>> operator will compare their addresses.
>>>
>>> Kinda had a feel it was straight out of chatGPT or similar.
>> 
>> ChatGPT isn't that stupid and is more likely to alert you that you are
>> doing a meaningless address compare than an actual string compare.
>
>Hopefully...

Sounds to me like you haven't used it for coding, or if you did, you
haven't used it recently.
-- 
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
            The Terminals Wiki <http://terminals-wiki.org>
     The Computer Graphics Museum <http://computergraphicsmuseum.org>
  Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>

[toc] | [prev] | [next] | [standalone]


#401127

From"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>
Date2026-08-13 14:39 -0700
Message-ID<115ldho$20u1b$2@dont-email.me>
In reply to#401108
On 8/13/2026 7:09 AM, Richard wrote:
> "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> spake the secret code
> <115g4af$b6pj$1@dont-email.me> thusly:
> 
>> On 8/11/2026 8:10 AM, Richard wrote:
>>> kymhorsell@gmail.com spake the secret code
>>> <115e6ta$120f$2@nnrp.usenet.blueworldhosting.com> thusly:
>>>
>>>> In comp.lang.c Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>>>>> The troll's claim was that it's a good idea to use "/GF" in Visual
>>>>> Studio if you want to compare strings with "==".
>>>>>
>>>>> This is, of course, a remarkably bad idea (and a common error by
>>>>> inexperienced C programmers).  C strings, whether literals or not,
>>>>> should be compared using strcmp() or something similar.  The "=="
>>>>> operator will compare their addresses.
>>>>
>>>> Kinda had a feel it was straight out of chatGPT or similar.
>>>
>>> ChatGPT isn't that stupid and is more likely to alert you that you are
>>> doing a meaningless address compare than an actual string compare.
>>
>> Hopefully...
> 
> Sounds to me like you haven't used it for coding, or if you did, you
> haven't used it recently.

No. I code myself. Btw, I have messed around with it and the bastard 
gave me some lock-free code that was simply infested with 
race-conditions! So, I kind of gave up on it.

[toc] | [prev] | [next] | [standalone]


#401128

From"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>
Date2026-08-13 14:41 -0700
Message-ID<115ldlv$20u1b$3@dont-email.me>
In reply to#401127
On 8/13/2026 2:39 PM, Chris M. Thomasson wrote:
> On 8/13/2026 7:09 AM, Richard wrote:
>> "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> spake the secret 
>> code
>> <115g4af$b6pj$1@dont-email.me> thusly:
>>
>>> On 8/11/2026 8:10 AM, Richard wrote:
>>>> kymhorsell@gmail.com spake the secret code
>>>> <115e6ta$120f$2@nnrp.usenet.blueworldhosting.com> thusly:
>>>>
>>>>> In comp.lang.c Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>>>>>> The troll's claim was that it's a good idea to use "/GF" in Visual
>>>>>> Studio if you want to compare strings with "==".
>>>>>>
>>>>>> This is, of course, a remarkably bad idea (and a common error by
>>>>>> inexperienced C programmers).  C strings, whether literals or not,
>>>>>> should be compared using strcmp() or something similar.  The "=="
>>>>>> operator will compare their addresses.
>>>>>
>>>>> Kinda had a feel it was straight out of chatGPT or similar.
>>>>
>>>> ChatGPT isn't that stupid and is more likely to alert you that you are
>>>> doing a meaningless address compare than an actual string compare.
>>>
>>> Hopefully...
>>
>> Sounds to me like you haven't used it for coding, or if you did, you
>> haven't used it recently.
> 
> No. I code myself. Btw, I have messed around with it and the bastard 
> gave me some lock-free code that was simply infested with race- 
> conditions! So, I kind of gave up on it.

However, I did use it to teach me about some of the dx12 api's. It was 
pretty good there.

[toc] | [prev] | [next] | [standalone]


#401013

FromBonita Montero <Bonita.Montero@gmail.com>
Date2026-08-11 19:17 +0200
Message-ID<115flfs$63aq$1@raubtier-asyl.eternal-september.org>
In reply to#400934
Am 08.08.2026 um 23:39 schrieb Johann 'Myrkraverk' Oskarsson:
> Dear comp.lang.c, comp.os.ms-windows.programmer.win32,
> and perhaps other groups that may make use of this information, but I
> don't know about.
> When you want to use == to compare strings such as "a", with "b" because
> all your strings are constants, ...
When do you compare the address of string literals ? I guess that's
very rare. Today's compilers / linkers not only join string-literals
on the same address when they're the same but any static data (comdat
folding). The potential for mistakes with that seems very little for
me.

[toc] | [prev] | [next] | [standalone]


#401020

FromRichard Harnden <richard.nospam@gmail.invalid>
Date2026-08-11 20:16 +0100
Message-ID<115fseb$8ioh$1@dont-email.me>
In reply to#401013
On 11/08/2026 18:17, Bonita Montero wrote:
> Am 08.08.2026 um 23:39 schrieb Johann 'Myrkraverk' Oskarsson:
>> Dear comp.lang.c, comp.os.ms-windows.programmer.win32,
>> and perhaps other groups that may make use of this information, but I
>> don't know about.
>> When you want to use == to compare strings such as "a", with "b" because
>> all your strings are constants, ...
> When do you compare the address of string literals ? 

When they've all come via a hash.

I guess that's
> very rare. Today's compilers / linkers not only join string-literals
> on the same address when they're the same but any static data (comdat
> folding). The potential for mistakes with that seems very little for
> me.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.c


csiph-web