Actions
Bug #8224
closedlibshell: operation on '_Fcin.fcptr' may be undefined
Start date:
2017-05-13
Due date:
% Done:
100%
Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:
External Bug:
Description
Building with gcc 6:
../common/sh/lex.c: In function 'sh_lex': ../common/include/fcin.h:49:39: error: operation on '_Fcin.fcptr' may be undefined [-Werror=sequence-point] #define fcseek(n) ((char*)(_Fcin.fcptr+=(n))) ^ ../common/sh/lex.c:1089:7: note: in expansion of macro 'fcseek' fcseek(state-(fcseek(0))); ^~~~~~ cc1: all warnings being treated as errors
Updated by Toomas Soome over 5 years ago
The background for this warning is about the fact that not all operations have clearly defined sequence order, and so the compiler is trying to warn about such cases, so that we would know that this particular sequence may end up producing different results.
The solution used in this particular case is to split the pointer operation to separate units by using temporary variable for middle result. Note the problem is there because the fcseek() is macro and is expanded by preprocessor, so we can not assume the function like semantics.
Of course the alternate solution would be to convert fcseek() to real function, thus achieving the determined sequence points.
Updated by Electric Monk over 5 years ago
- Status changed from In Progress to Closed
- % Done changed from 90 to 100
git commit f25e629a56ba86e6dfc1e50a16f54fdffee36eac
commit f25e629a56ba86e6dfc1e50a16f54fdffee36eac Author: Toomas Soome <tsoome@me.com> Date: 2017-08-01T19:03:15.000Z 8224 libshell: operation on '_Fcin.fcptr' may be undefined Reviewed by: Marcel Telka <marcel@telka.sk> Reviewed by: Robert Mustacchi <rm@joyent.com> Approved by: Richard Lowe <richlowe@richlowe.net>
Actions