Path: csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Norman Goldstein Newsgroups: gnu.utils.bug Subject: ld resolving different types Date: Sat, 15 Feb 2020 16:51:14 -0800 Lines: 58 Approved: bug-gnu-utils@gnu.org Message-ID: References: <4cb01f16-bfc7-73cc-183c-ad6e8c76863c@telus.net> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------3EB77AC8F063B3C5EBF0BFAA" X-Trace: usenet.stanford.edu 1581814282 32370 209.51.188.17 (16 Feb 2020 00:51:22 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-gnu-utils@gnu.org Envelope-to: bug-gnu-utils@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telus.net; s=neo; t=1581814276; bh=cq4xc0PN6V25t/EaiX5sPCx5q21nZolB3AFtC472id8=; h=To:From:Subject:Date; b=4duzaiE5VA3G/hKymWW3WvDQ4JfNKHYRLr/HhaB3ikCJsdwib/vMzh5WtpOXbd7jo AhHJFHJAVg7YqQ9ZLIcwMWz/kNf8JhGgfQQOZL3UQ3jABUpVtPoRcdN7RJbcqw/l7h VIPA+gfaxAVLsHQgKQUwTEOvP+QtldW8gQG/02YbzjS0cb+pqcWibHzpWxjlTVKMBB dwVop9rofOMQ+/ADSRc7xiUkvXYdE0+JZ7GqSztMZgggxg7vkA8CApCCkf1Bupckq6 836/O499uo85oKxVG7H4SQmDLdFR4ggx73krE/BvUKR29YsL5HCrYAbE08yEidZ27c iDKShkpSVdDMw== X-Telus-Authed: none X-Authority-Analysis: v=2.3 cv=NruvjPVJ c=1 sm=1 tr=0 a=c259RqH085UPayaMlDPCbg==:117 a=c259RqH085UPayaMlDPCbg==:17 a=r77TgQKjGQsHNAKrUKIA:9 a=XHpaKe1UTmEfAaAY-OUA:9 a=QEXdDO2ut3YA:10 a=ZEFxYL02n5T86OWtuTkA:9 a=rIuRI2yWBtNG4DHt:21 a=_W_S_7VecoQA:10 a=ImacjLIl88_p1lyM-yMA:9 a=wMH6IVgj0cQA:10 a=13GrU3uAPTC6WrIgSZEA:9 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 Content-Language: en-CA X-CMAE-Envelope: MS4wfCO0pi7sOnrXdX+L7LWPBWUmexaaSA0PzyESvwRh4GcKd02Q191vv/WDf0YxfI3C4UWbAyGQE7/OThiSFMlXw3e2X/aEotSwZ2P8CkqwFyE/7tyyk6Tn GRQdfXN8J6EDv6bSSDEIUJ6lX3BDa7ex/70IdFKXu73xkM6Dght+WmvA X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.171.16.92 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: bug-gnu-utils@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports for the GNU utilities List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <4cb01f16-bfc7-73cc-183c-ad6e8c76863c@telus.net> Xref: csiph.com gnu.utils.bug:2276 This is a multi-part message in MIME format. --------------3EB77AC8F063B3C5EBF0BFAA Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit LD version:    GNU ld version 2.31.1-37.fc30 Platform:    Linux 5.4.17-100.fc30.x86_64 #1 SMP     x86_64 x86_64 x86_64 GNU/Linux Compile/Link command:     gcc tlink.cpp tlink2.cpp -o tlink -lstdc++ The programs compiles and links without warning or error, but resolves /extern int foo/ with /double foo/.  The result of running the program is, of course, garbage: foo= -858993459 The program contains only 1 definition for foo (the extern statement is a declaration), so the program is not violating the One Definition Rule. Thank you. --------------3EB77AC8F063B3C5EBF0BFAA Content-Type: text/x-c++src; charset=UTF-8; name="tlink.cpp" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="tlink.cpp" #include using namespace std; extern int foo; int main( int argc, char* argv[] ) { cout << "foo= " << foo << endl; return 0; }// main --------------3EB77AC8F063B3C5EBF0BFAA Content-Type: text/x-c++src; charset=UTF-8; name="tlink2.cpp" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="tlink2.cpp" double foo = 2.1; --------------3EB77AC8F063B3C5EBF0BFAA--