Home > Gcc Error > Gcc Error Operation On May Be Undefined

Gcc Error Operation On May Be Undefined

Contents

asked 3 years ago viewed 3702 times active 3 years ago Linked 3 warning “operation on may be undefined” 0 Are “Statement and Declarations in Expressions” specific to GNU C? At first blush, it *looks* like the arguments were evaluatedfrom right to left (if x = 1, then x++ evaluates to 1, with the sideeffect that x == 2, and ++x so I think the real reason is something about sequence point. I was hoping H2C03 would elaborate on his comment. –Shafik Yaghmour May 30 '13 at 14:57 Just compiled the sample with gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3, with gcc -Wall -Wsequence-point... navigate here

The evaluation of the arguments occurs before the function is called, and is not part of "the actions associated with each specifier". An implementation can do whatever it wants with undefined behaviour *including* document what it does (the standard even says it is allowed to document it). Registration is quick, simple and absolutely free. Is there a role with more responsibility? http://stackoverflow.com/questions/10623114/operation-on-may-be-undefined

Wsequence-point Gcc

The ambiguity is whether the LHS will use the pre-increment or post-increment value. thx Nov 15 '05 #25 P: n/a Keith Thompson "jimjim" writes: If I were more familiar with the details of gcc's code generation, I might, but such a guess would Robert Gamble Nov 15 '05 #31 This discussion thread is closed Start new discussion Replies have been disabled for this discussion. It is more like: Code: void function(SomeType* ptr) { ptr->count = ++ptr->count % 10; return; } In which case ptr->count has been initialized prior to calling this function.

Meaning of "oh freak" What are oxidation states used for? Why when run the output is: "3 2 1"? of the atom whose 1s electron moves nearly at the speed of light? Thanks, -paul- On Friday 01 October 2004 03:57, Mathieu Malaterre wrote: > I am trying gcc4, and turning -Wall reveal a strange warning: > > int main() > { > int

Is implementation-defined stated in particular sections of the Standard? Shift Operation Operation undefined fault element in operation but not in binding System.Net.WebException: The operation has timed-out Arithmetic shift operation in C Which operation is more expensive?(a <= b and a Therefore, we must do this. http://stackoverflow.com/questions/16838884/why-i-got-operation-may-be-undefined-in-statement-expression-in-c uk...

In it, you'll get: The week's top questions and answers Important community announcements Questions that need answers see an example newsletter By subscribing, you agree to the privacy policy and terms How can I make LaTeX break the word at the end of line more beautiful? If you are unwilling to do that and want me to look it up and quote it to you, you've got the wrong guy. -- Joe Wright "Everything should be made The problem is that the exact order in which all of those side effects are applied (assignment, postincrement, and preincrement) is unspecified; the compiler is free to reorder those operations as

Werror=sequence-point

You should be careful about depending on such things, though, since they likely won't work the same way on other implementations. -- Keith Thompson (The_Other_Keith) ks***@mib.org San Diego Supercomputer Center http://www.linuxquestions.org/questions/programming-9/warning-operation-on-'i'-may-be-undefined-%5B-wsequence-point%5D-4175483778/ This is just how C is defined (or not-well-defined as the case may be). –user166390 Mar 31 '12 at 0:40 I'm not a C programmer, but from the look Wsequence-point Gcc In this case that means you're not allowed to both increment trackTail[nodeNumber-1] using ++ and reassign it using =. C Sequence Point I'll accept his answer again because it surely avoids warnings anyhow.:) If I decided to ask a new question, I'll update this question to add a link.

because the documentary also said If you use some other kind of statement last within the braces, the construct has type void, and thus effectively no value. Developing web applications for long lifespan (20+ years) Filter columns basing on the value of other column Book of zen kōans Generate a 6 character string from a 15 character alphabet The ambiguity is whether the LHS will use the pre-increment or post-increment value. If the compiler did exactly this with the flaky code, then my fix is valid.

See http://publications.gbdirect.co.uk/c...ce_points.html August Nov 15 '05 #7 P: n/a jimjim > (b) Given the compiler warning, why are you surprised at the output? If you compute the address first, then the value to be stored, the result would be that of: a[i] = i; i++; Which is probably what was intended in first place. Nov 15 '05 #11 P: n/a Joe Wright jimjim wrote:Given that my compiler is the gcc, could you have a guess why is it 3 2 1and not 1 2 3? Technology is 'stuff that doesn't work yet.' -- Bran Ferren Reply With Quote 10-Mar-2010,04:30 #2 hcvv View Profile View Forum Posts View Blog Entries View Articles Global Moderator Join Date Jun

Unsubstantiated In a long sum, how can we find how many terms are preceded by the plus (or minus) sign Export The $PATH Variable, Line-By-Line Why did my electrician put metal With modern technology, is it possible to permanently stay in sunlight, without going into space? Indeed, this is a "standard" way of extending C.

Only if a and b point to the same thing, but if the caller is in a separate translation unit, there's no way to know that at compile time.

IQ Puzzle with no pattern Physically locating the server Compute the kangaroo sequence Is the NHS wrong about passwords? Search this Thread 11-07-2013, 03:56 PM #1 dbrazeau Member Registered: Aug 2009 Distribution: Fedora, OpenSuse, DENX Embedded Linux Posts: 176 Rep: warning: operation on 'i' may be undefined [-Wsequence-point] Is there a possibility for an implementation to choose some behavior for a Standard-specified Undefined behaviour and document it? My code is a little more complicated than that.

The text prefixed by ">> " was mine, so it should be preceded by something like Keith Thompson writes: It's easier to follow the discussion when we can see who more hot questions question feed lang-c about us tour help blog chat data legal privacy policy work here advertising info mobile contact us feedback Technology Life / Arts Culture / Recreation I don't know what other compilers would do. Appease Your Google Overlords: Draw the "G" Logo How to show hidden files in Nautilus 3.20.3 Ubuntu 16.10?

it is explained that the last thing in the compound statement should be an expression followed by a semicolon but not which purpose it serves. For example: int i = 5; i = i * i; is perfectly legal, and the value of i is accessed twice (the compiler might optimize accesses and remember the value Last edited by mina86; 11-08-2013 at 11:07 AM. Does it mean that g++ will always throw this warning for compound statements that have a for-loop at the end?

Last edited by dbrazeau; 11-07-2013 at 06:05 PM. 1 members found this post helpful. Dave Korn wrote: > I'm nitpicking, but considering it's a pre-increment, I'd have said > > zero = (zero + 1) % 3; > or > zero = zero + 1; Is implementation-defined stated in particular sections of the Standard? TIA You're running into two issues: 1.

hoping you would elaborate on your comment –FLanS39 Jun 1 '13 at 9:36 add a comment| 1 Answer 1 active oldest votes up vote 5 down vote accepted According to the Save β to j. 5. Anyway, see the FAQ: http://www.eskimo.com/~scs/C-faq/q3.2.html -David Nov 15 '05 #2 P: n/a Antonio Contreras jimjim wrote: Hello, #include int main(int argc, char *argv[]) { int x = 1; printf("%d %d In an expression that contains no sequence points an object may not be modified and accessed in different subexpressions (since the side effects of the subexpressions may take place in any

operator do?5Why does this (i = ++i % 3) generate a warning: “may be undefined”?2why *foo ++= *++foo may be undefined?612Divide a number by 3 without using *, /, +, -, You can't add something to something that doesn't exist. –Hosh Sadiq Mar 31 '12 at 0:41 You're incrementing 3 times inside the loop. In the United States is racial, ethnic, or national preference an acceptable hiring practice for departments or companies in some situations?

© 2017 imagextension.com