[LLVMbugs] [Bug 13553] New: Different behavior between g++ and clang++ when evaluating function calls as parameters
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Aug 8 12:45:51 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=13553
Bug #: 13553
Summary: Different behavior between g++ and clang++ when
evaluating function calls as parameters
Product: clang
Version: unspecified
Platform: Macintosh
OS/Version: MacOS X
Status: NEW
Severity: enhancement
Priority: P
Component: C++
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: wilbert at jdg.info
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
When compiling the following code:
=============================================
#include <iostream>
int Func1()
{
std::cout << "In Func1" << std::endl;
return 1;
}
int Func2()
{
std::cout << "In Func2" << std::endl;
return 2;
}
void FuncA(int a, int b)
{
}
int main(int argc, const char **argv)
{
FuncA( Func1(), Func2() );
return 0;
}
==============================================
And building it with g++ and clang++:
> g++ test.cpp -o test-g++
> clang++ test.cpp -o test-clang++
And executing the builds then the actual output is different:
> ./test-g++
In Func2
In Func1
> ./test-clang++
In Func1
In Func2
I can imagine that this could lead to some really hard to track issues when
people are switching from gcc (or VS2010) ro clang.
I am also not sure how this is defined in the C/C++ specs.
The versions used (standard XCode 4.4 binaries):
> g++ --version
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658)
(LLVM build 2336.11.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> clang++ --version
Apple clang version 4.0 (tags/Apple/clang-421.0.57) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin12.0.0
Thread model: posix
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list