https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78080
Bug ID: 78080 Summary: chown command (sys/stat.h) fail to change the owner directory if the return value is not attributed to a variable. Product: gcc Version: 5.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: rosemberg at ymail dot com Target Milestone: --- Hi, chown command (sys/stat.h) fail to change the owner directory if the return value is not attributed to a variable. Supposed the directory /home/user/tochange exists and the program is running with administrator rights and tochange owner and group is not the same like its parent directory . example of success code: #include <string> #include <iostream> #include <sys/stat.h> int main() { string sPath("/home/user/tochange"); struct stat info; stat("/home/user",&info); int iA = chown(sPath.c_str(), info.st_uid, info.st_gid); cout << iA << endl; return 0; } The result to iA will be 0 (success) If I change the last 2 lines (before return 0;) to the follow code, the chown command failed and cout will return -1 (nothing was changed): cout << chown(sPath.c_str(), info.st_uid, info.st_gid) << endl; it also happened with if statement. Best regards, M.Rosemberg