I just fixed a bug. Namely, the C++ function:

void returnCharPtr(char * someString, int n);

cannot return any CharPtr because the someString pointer is passed by value. Also, the intent of the author was clear:

So, another option is to pass the parameter as an argument, so you process your string in a function but don't create a new copy.

But as the change was rejected (3 vs 2) the post stayed in an incorrect state (IMHO).

I left a comment to the author. Can I argue with the editors' decision?

  • 4
    That is not an valid edit. You are actually modifying the existing code. – Lucifer Mar 12 '14 at 11:47
  • 3
    You could have left a comment to the OP asking for this small change in the answer. Either the OP themselves or any user with the edit privilege coming across that would have validated the change and made it in case it was correct. I know that you were probably right with the edit, but generally, suggested code edits are not greatly appreciated because not everybody reviewing the edit would happen to know that technology to be able to validate it, thereby, more often than not, rejecting it. – SudoRahul Mar 12 '14 at 11:52
  • 2
    Editing code, in general, is a disputed practice because changing the code is changing someone else's work and their name is attached to it. Fixing legit and obvious typos is normally considered OK by everyone, but beyond that start getting into the gray area where some think it is OK and some thing it is wrong. If this is actually a typo (I wouldn't know since I don't know C++), then it is an acceptable edit. If it is a mistake that isn't an obvious typo, then you are getting into that gray area. – psubsee2003 Mar 12 '14 at 11:53
  • 3
    @Kedarnath - Correcting errors in code is a valid edit. The problem is that too many reviewers just reject instead of evaluating the edit correctness or skipping if they are unable to. – Martin Smith Mar 12 '14 at 11:54
  • @Kedarmath Sure, to make post correct and better as it is declared in the rules. Are there any rules forbidding editing the code? – Alexey Voytenko Mar 12 '14 at 11:56
  • 1
    @Ɍ.Ɉ I caught this. Probably I will not do this in the future. – Alexey Voytenko Mar 12 '14 at 11:59
  • 1
    @psubsee2003 "where some think it is OK and some thing it is wrong. " - in the case when compiler can judge there is unambiguous opinion. "If it is a mistake..., then you are getting into that gray area." You mean that it is better for the site to have posts with mistakes? – Alexey Voytenko Mar 12 '14 at 12:03
  • @AlexeyVoytenko no, of course, not. I was just explaining the overall views of the community. Personally, I think editing code in answers should not be considered as unacceptable as it is. Generally, leaving a comment as RJ suggested is how the community prefers issues like this be handled. – psubsee2003 Mar 12 '14 at 12:06
  • @AlexeyVoytenko, have you read this in help center ? Where does it mentioned that you are allowed to correct the wrong code ? – Lucifer Mar 12 '14 at 12:07
  • 3
    @Kedarnath - Correct minor mistakes is explicitly listed as a valid reason for editing. – Martin Smith Mar 12 '14 at 12:10
  • 1
    'Leaving a comment' works OK if a person will read it. But if it will not be changed a mistake in a sample code will stay and can mislead the asking person (a learner), and all other readers. It does not matter who will made the edit, but I suggest that there will be a competent moderator role to look at such issues, to whom we can appeal in such cases. It is really the scheme as code review works in professional programming. – Alexey Voytenko Mar 12 '14 at 12:19
  • 3
    @AlexeyVoytenko even if the author of the answer doesn't read and act on your comment, everyone who reads the answer can also read your comment. If you are seriously concerned, and a day or two has gone by without the answer being fixed, you can add your own answer that is correct and explain carefully the distinction that makes it correct. – Kate Gregory Mar 12 '14 at 12:40
  • 1
    @Kate Gregory "everyone who reads the answer can also read your comment." Can you read mine ? That should work, but much easier will be to fix a code. Changing the code is usual for programmers. – Alexey Voytenko Mar 12 '14 at 12:52
  • See, I think that's an invalid edit too... it's historical to pass C strings as a pointer, and a length - the target function can write up to n bytes at the target. But it's not clear what the original author meant. That's why it's not a good idea though - that answer is now under the author's name, but with code that is different from what the author posted. The only 'minor' changes that should actually be corrected is code that actual won't compile - if it's valid code, but you think it should be different, that should always be a comment. – Corley Brigman Mar 14 '14 at 18:09
  • @CorleyBrigman yep, it is always better to discuss with the author. But he still does not appeared. Reading again the post, we can conclude that memory should be allocated inside the returnCharPtr function - then my edit is correct. But let's wait for the author. "...that should always be a comment." - I do not agree. That is all my this question is about - if the code is not correct, and the author is absent, it is better to change the post to keep information correct. – Alexey Voytenko Mar 15 '14 at 23:37

Assuming that your code is correct (and I am taking your word on that as your C is better than mine), then it is an entirely proper edit. Please refer to https://meta.stackexchange.com/questions/200336/when-should-i-make-edits-to-code

Unfortunately, many members of SO like to reject anything that touches code, regardless of whether the edit makes SO a better resource or not. I have taken the liberty to make the edit to the post and referred to your question to explain why it was made.

Please don't let this discourage you from making other edits. Once you hit 2k, you won't have to deal with the suggested edit system. In the meantime, you may want to point to the FAQ I linked above in your edit summary along with explaining what you fixed (your suggested edit summary could have been more descriptive).

  • 1
    Unfortunately, many members of SO like to reject anything that touches code -- we need to show them the SKIP button... if unsure then SKIP - all reviewers should stick that on a wall above their beds ;) – user221081 Mar 14 '14 at 11:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .