---
title: "Discussion on \"Dubious code using pre-increment operator in C++\" | Hashnode"
description: "Discussion on \"Dubious code using pre-increment operator in C++\". pre increment operator ++ in c++ , operator precedence"
url: "https://hashnode.com/posts/dubious-code-using-pre-increment-operator-in-c/637cf801de1a8abc80caf993"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Dubious code using pre-increment operator in C++](https://sbiswajit.hashnode.dev/dubious-code-using-pre-increment-operator-in-c?utm_source=hashnode&utm_medium=feed)

pre increment operator ++ in c++ , operator precedence

Nov 22, 2022 · 2 min read · sbiswajit.hashnode.dev  
Read the article

-   [#programming](https://hashnode.com/tag/programming)
-   [#cpp](https://hashnode.com/tag/cpp)
-   [#c](https://hashnode.com/tag/c)
-   [#programming-blogs](https://hashnode.com/tag/programming-blogs)
-   [#programming-tips](https://hashnode.com/tag/programming-tips)

## Written by

[SBISWAJIT BHANJA](https://hashnode.com/@SBISWAJIT)

@SBISWAJIT · BBSR, ODISHA

  
[View profile](https://hashnode.com/@SBISWAJIT)

MCA @SILICON BBSR

I am basically a student pursuing my MCA at SIT, Bhubaneswar. I love coding and I have my interests in open source software, Front-end web development and Responsive web design...

## Responses 1

Markdown supported · ⌘↵ to post

[Luke Li](https://hashnode.com/@infgeoax)

[Nov 28, 2022](https://hashnode.com/posts/dubious-code-using-pre-increment-operator-in-c/637cf801de1a8abc80caf993/comment/638401ed43c7ea1599a5f216)

This is undefined behavior in C++ and you should **never** write code like this, and do not bother to make sense of the compiler's output, it's a waste of time.

It boils down to "unsequenced multiple modifications" to the same memory location `n`, i.e. they can happen in any order.

P.S. Always add `-Wall` when compiling with gcc.
