Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6113057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:48:55+00:00 2026-05-23T14:48:55+00:00

I was recently surprised to note that compiling with /GS (Enable buffer security check)

  • 0

I was recently surprised to note that compiling with /GS (Enable buffer security check) in MSVC++ 2010 seems to have a non-negligible effect on run-time performance in some cases. Has anyone else had this experience??

For a large scientific-style application (a mesh generation library) it seems that compiling with /GS- can lead to almost 10% improvements in run-time for several of the large benchmarks in my test suite ("large" being >= 1 second worth of run-time). /GS is on by default at all levels of optimisation in MSVC++ 2010.

I must admit that I’d never paid too much attention to this option before, and I’m wanting a bit of clarification as to what it actually does. The online documentation seems to talk extensively about string buffers, but since I don’t use string or char[] buffers anywhere I must be missing something.

This paragraph (from the online doc) seems to indicate that the performance degradation I’m seeing is a bit unusual:

A performance tradeoff for using
security checks in an application must
be made. The Visual C++ compiler team
focused on making the performance
degradation small. In most cases, the
performance should not degrade more
than 2 percent. In fact, experience
has shown that most applications,
including high-performance server
applications, have not noticed any
performance impact.

Of course I can just turn it off, and get faster code, but I want to understand the implications before I do that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:48:56+00:00Added an answer on May 23, 2026 at 2:48 pm

    /GS adds code that tries to detect if a write overrun or similar stack attack has happend during a function, and to stop execution after a write overrun. The patterns that it aims to find are ones that have been seen in real-world attacks. There are a bunch of real world security bulletins that would not have happened if today’s /GS had been in use at the time.

    In this case a write overrun can happen on structures, arrays and various other entities. Changes and improvements to /GS are made in each version of VS. More /GS protection generally has cost, although in some cases newer VS may have learnt how to do the same protection cheaper.

    I’d recommend leaving /GS on unless your code doesn’t ship to others – generally the protection is worth the cost; at most you might choose to disable it for specific functions where there is no risk and high impact – just as you might hand-optimise the most critical parts of your program in other ways.

    Martyn

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was surprised recently to find that it's possible to have a return statement
I have recently become aware that our code has several implementations of a version
I was surprised recently to discover that the compiler is apparently not strict about
I recently started learning Python and I was rather surprised to find a 1000
Recently I have been investigating the possibilities of caching in ASP.NET. I rolled my
I was recently advocating to a colleague that we replace some C# code that
I have always believed that Debug builds are slower than Release builds since the
I saw a tweet recently that confused me (this was posted by an XNA
Recently Jeff has posted regarding his trouble with database deadlocks related to reading. Multiversion
Recently, I started changing some of our applications to support MS SQL Server as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.