From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id AO/ZLOlzZ2CQ1gAAgWs5BA (envelope-from ) for ; Fri, 02 Apr 2021 21:43:37 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id aNu4JulzZ2AVHAAAbx9fmQ (envelope-from ) for ; Fri, 02 Apr 2021 19:43:37 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id EEFF31FB83 for ; Fri, 2 Apr 2021 21:43:36 +0200 (CEST) Received: from localhost ([::1]:59990 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lSPhf-0008Hj-Of for larch@yhetil.org; Fri, 02 Apr 2021 15:43:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45962) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lSNmR-0003WO-Vq for emacs-orgmode@gnu.org; Fri, 02 Apr 2021 13:40:28 -0400 Received: from w4.tutanota.de ([81.3.6.165]:34808) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lSNmK-0002SJ-50 for emacs-orgmode@gnu.org; Fri, 02 Apr 2021 13:40:21 -0400 Received: from w3.tutanota.de (unknown [192.168.1.164]) by w4.tutanota.de (Postfix) with ESMTP id CBC5D10601FD for ; Fri, 2 Apr 2021 17:40:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1617385211; s=s1; d=tutamail.com; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Cc:Date:Date:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:Sender; bh=ceNpK1xVoCZDNphVzLYYNWiic4SPcaS250rAFWMfEZg=; b=BLpJpLPEjbMy8TVZdP5HSJpbQrjR+WBsj6V0ZoxN69kkRLj9cZBrDzO32PxfHWdj UmOVYW86HIc304PUTQbiMkbsZ7IazRsEiIvRFV/FkHfuCT+qXEFm06gRtCM1iI0oUM/ T8pzXKGSkPAFJektN4NGO4lUhiTX3KzXZQRTVonEDZe7xogBsgAW5v0KrqcL7kyrOoY vPeD6XlQrqGu2EWb7902fXoGQn5TzVh8YxeQFP3mlkugH+zs4BENXE41DJcctTF1ng3 kFXcQYAM/Y2VKznCYPls+ITC57bmHkoz5hSMmKBnXxBa+xBIViv1SCU0stJW4wiioc6 WajFKERWlQ== Date: Fri, 2 Apr 2021 19:40:11 +0200 (CEST) To: emacs-orgmode@gnu.org Message-ID: Subject: Bug: Incompatible return type in org-babel C when using a table of doubles with a header as a variable [9.4.4 (release_9.4.4-272-ga9f38b @ /home/richard/.emacs.d/straight/build/org/)] MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_194117_563920015.1617385211814" Received-SPF: pass client-ip=81.3.6.165; envelope-from=richard.j.sent@tutamail.com; helo=w4.tutanota.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 02 Apr 2021 15:42:58 -0400 X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" Reply-to: Richard Sent From: Richard Sent via "General discussions about Org-mode." X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1617392617; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=ceNpK1xVoCZDNphVzLYYNWiic4SPcaS250rAFWMfEZg=; b=kqjtFU+3ClSKGJS7Sb87x7ZTPp+dNMhLlWp14/fSMPxov6Z3VjVE4bvmiXklzAqSz8x8d4 vVhgJP2sIHvBlJe7bLUxmb74DS0aTYY30nl50aZJuOftQ8/JwrgtpNdZDuP9wMwJ+t2ohA kqTiyJnW6X5AFyIDSRNImFY4L3o5h4skngubOYohXRwpqZPTJ9xOu9uK/14c1S+hds0K8L yiABmBfH+ZoiB6LEwmp5k5InIftqjrB1cGbjPu+7A70/Fg+CADb+14L+mvmkNu7ByxyqdA bsVmPOf/03sumOlCL1fw3WD2Gzyq0uEHiVGMsh+oz1Nbmd1XUkx0m4KlRrS5Kw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1617392617; a=rsa-sha256; cv=none; b=G7cB49NjfNdFdxHn9IsaR2ruvJzvo3DV6HDtIcykHDO7tGDjek+PedEUQVbzB9w4gXlY/w Gdrl+CwH20q2bxmOgv5YDJ0co4QsLAooR8u6nD+sYsKIdapJQ2daVRGcGm4V8YjtqCPOmb eZNr1pNMOwpbq3EKPNPGr6gh7BxG6Yxc9N9scxnyxE/N8xtvQkMXm6HsBysKp8Yx2NLnxT lRUYUblTae4jnhc8+KMK5U8qxDe0GYWPK3lBztw/OpJ75qX3OgkCRkqgCeKyIcqSx9EZFQ 8KnZKstVrRMB8/XuCuGi8N/v0hxUDEFEt+L6/oX/alxpYaLrdqy17UEjw+yjmQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=tutamail.com header.s=s1 header.b=BLpJpLPE; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -1.43 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=tutamail.com header.s=s1 header.b=BLpJpLPE; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: EEFF31FB83 X-Spam-Score: -1.43 X-Migadu-Scanner: scn0.migadu.com X-TUID: a4s/p5CtR4Ha ------=_Part_194117_563920015.1617385211814 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable When a table of floating pointer numbers that contains a header row is set as a variable to a C source block, the generated header file contains an invalid return type, causing the program to not compile. For example, if I have a table that looks like #+NAME: tbl-doubles-org-bug-report #+begin_src C :includes :results table :colnames '("i" "val") =C2=A0 for (int i =3D 0; i < 5; i++) { =C2=A0=C2=A0=C2=A0 printf("%f %f\n", (double)i, i * 2.0); =C2=A0 } #+end_src #+RESULTS: tbl-doubles-org-bug-report |=C2=A0=C2=A0 i | val | |-----+-----| | 0.0 | 0.0 | | 1.0 | 2.0 | | 2.0 | 4.0 | | 3.0 | 6.0 | | 4.0 | 8.0 | And then attempt to include that table as a variable called data #+begin_src C :includes stdio.h :var data=3Dtbl-doubles-org-bug-report =C2=A0 printf("No errors!"); #+end_src Nothing is printed, and *Org-Babel Error Output* will display /tmp/babel-NQHi51/C-src-lsA892.c: In function =E2=80=98data_h=E2=80=99: /tmp/babel-NQHi51/C-src-lsA892.c:24:65: error: incompatible types when retu= rning type =E2=80=98double=E2=80=99 but =E2=80=98const char *=E2=80=99 was = expected =C2=A0=C2=A0 24 | const char* data_h (int row, const char* col) { return da= ta[row][get_column_num(2,data_header,col)]; } =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ~~~~~~~~~^~= ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /bin/bash: line 1: /tmp/babel-NQHi51/C-bin-90Zk27: Permission denied If we look in the /tmp file mentioned, it's easy to see the inconsistency. double data[5][2] =3D { {0.000000,0.000000}, {1.000000,2.000000}, {2.000000,4.000000}, {3.000000,6.000000}, {4.000000,8.000000} }; const int data_rows =3D 5; const int data_cols =3D 2; int get_column_num (int nbcols, const char** header, const char* column) { =C2=A0 int c; =C2=A0 for (c=3D0; c
When a table of floating pointer numbers that contains a header row is=
set as a variable to a C source block, the generated header = file
contains an invalid return type, causing the program to = not compile.

For example, if I have a table th= at looks like

#+NAME: tbl-doubles-org-bug-repo= rt
#+begin_src C :includes <stdio.h> :results table :co= lnames '("i" "val")
  for (int i =3D 0; i < 5; i++) {=
    printf("%f %f\n", (double)i, i * 2.0);
  }
#+end_src

#= +RESULTS: tbl-doubles-org-bug-report
|   i | val |<= br>
|-----+-----|
| 0.0 | 0.0 |
| 1.0= | 2.0 |
| 2.0 | 4.0 |
| 3.0 | 6.0 |
<= div>| 4.0 | 8.0 |

And then attempt to include = that table as a variable called data

#+begin_s= rc C :includes stdio.h :var data=3Dtbl-doubles-org-bug-report
  printf("No errors!");
#+end_src

Nothing is printed, and *Org-Babel Error Output* will display

/tmp/babel-NQHi51/C-src-lsA892.c: In function =E2= =80=98data_h=E2=80=99:
/tmp/babel-NQHi51/C-src-lsA892.c:24:65= : error: incompatible types when returning type =E2=80=98double=E2=80=99 bu= t =E2=80=98const char *=E2=80=99 was expected
   24= | const char* data_h (int row, const char* col) { return data[row][get_col= umn_num(2,data_header,col)]; }
     = |            &= nbsp;           &nbs= p;            &= nbsp;           &nbs= p;      ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~
/bin/bash: line 1: /tmp/babel-NQHi51/C-bin-90Zk27: Permiss= ion denied

If we look in the /tmp file mention= ed, it's easy to see the
inconsistency.

double data[5][2] =3D {
{0.000000,0.000000},
{1.000000,2.000000},
{2.000000,4.000000},
{3.000000,6.000000},
{4.000000,8.000000}
};
const int data_rows =3D 5;
const int data_cols = =3D 2;
int get_column_num (int nbcols, const char** header, c= onst char* column)
{
  int c;
  for (c=3D0; c<nbcols; c++)
    if = (strcmp(header[c],column)=3D=3D0)
    &nb= sp; return c;
  return -1;
}
const char* data_header[2] =3D {"i","val"};
const char* data= _h (int row, const char* col) { return
data[row][get_column_n= um(2,data_header,col)]; }
int main() {
printf("= No errors!");
return 0;
}

data_h() should not return a const char*, but a double.

I've also tested this with $ emacs -Q and the issue is st= ill present. It
does not occur if the table contains integer = values instead of floats
or if a header row is omitted. Seeing as how th= e header row is processed
differently from the data, I don't = think the presence of a header row is
meant to cause this err= or.



Emacs  = : GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.22, cairo= version 1.17.3)
of 2020-08-28
Package: Org mod= e version 9.4.4 (release_9.4.4-272-ga9f38b @ /home/richard/.emacs.d/straigh= t/build/org/)

current state:
=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
(setq
o= rg-src-mode-hook '(org-src-babel-configure-edit-buffer org-src-mode-configu= re-edit-buffer doom-modeline-set-org-src-modeline)
org-link-s= hell-confirm-function 'yes-or-no-p
org-blank-before-new-entry= '((heading . t) (plain-list-item . t))
org-metadown-hook '(o= rg-babel-pop-to-session-maybe)
org-clock-out-hook '(org-clock= -remove-empty-clock-drawer)
org-html-format-inlinetask-functi= on 'org-html-format-inlinetask-default-function
org-odt-forma= t-headline-function 'org-odt-format-headline-default-function
org-agenda-files '("~/org")
org-ascii-format-inlinetask-func= tion 'org-ascii-format-inlinetask-default
org-startup-folded = t
org-mode-hook '(#[0 "\301\211=10\207" [imenu-create-index-f= unction org-imenu-get-tree] 2]
#[0 "\300\301\302\303\304$\207= " [add-hook change-major-mode-hook org-show-all append local] 5]
<= div>#[0 "\300\301\302\303\304$\207" [add-hook change-major-mode-hook org-ba= bel-show-result-all append local] 5]
org-babel-result-hide-sp= ec org-babel-hide-all-hashes turn-on-auto-fill mixed-pitch-mode org-superst= ar-mode
highlight-parentheses-mode)
org-odt-for= mat-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"]
org-archive-hook '(org-attach-archive-delete-maybe)
org-co= nfirm-elisp-link-function 'yes-or-no-p
org-agenda-before-writ= e-hook '(org-agenda-add-entry-text)
org-metaup-hook '(org-bab= el-load-in-session-maybe)
org-bibtex-headline-format-function= #[257 "\300=01\236A\207" [:title] 3 "\n\n(fn ENTRY)"]
org-ad= apt-indentation nil
org-latex-format-drawer-function #[514 "\= 207" [] 3 "\n\n(fn _ CONTENTS)"]
org-babel-pre-tangle-hook '(= save-buffer)
org-file-apps '(("\\.pdf\\'" . emacs) (auto-mode= . emacs) (directory . emacs) ("\\.mm\\'" . default) ("\\.x?html?\\'" . def= ault)
("\\.pdf\\'" . default))
org-tab-first-ho= ok '(org-babel-hide-result-toggle-maybe org-babel-header-arg-expand)
org-hide-leading-stars t
org-babel-load-languages '((= C . t) (emacs-lisp . t))
org-log-done 'time
org= -superstar-leading-bullet 32
org-ascii-format-drawer-function= #[771 "=01\207" [] 4 "\n\n(fn NAME CONTENTS WIDTH)"]
org-age= nda-loop-over-headlines-in-active-region nil
org-occur-hook '= (org-first-headline-recenter)
org-cycle-separator-lines 1
=
org-export-before-processing-hook '(org-blackfriday--reset-org-b= lackfriday--code-block-num-backticks)
org-cycle-hook '(org-cy= cle-hide-archived-subtrees org-cycle-hide-drawers org-cycle-show-empty-line= s
  org-optimize-window-after-visibility-change)
org-speed-command-hook '(org-speed-command-activate org-babel-speed-= command-activate)
org-clock-persist-file "/home/richard/.emac= s.d/var/org/clock-persist.el"
org-superstar-leading-fallback = 8229
org-odt-format-inlinetask-function 'org-odt-format-inlin= etask-default-function
org-latex-prefer-user-labels t
org-babel-tangle-lang-exts '(("D" . "d") ("C++" . "cpp") ("emacs-lis= p" . "el") ("elisp" . "el"))
org-publish-timestamp-directory = "/home/richard/.emacs.d/var/org/timestamps/"
org-export-befor= e-parsing-hook '(org-attach-expand-links)
org-id-locations-fi= le "/home/richard/.emacs.d/var/org/id-locations.el"
org-confi= rm-shell-link-function 'yes-or-no-p
org-link-parameters '(("a= ttachment" :follow org-attach-follow :complete org-attach-complete-link) ("= id" :follow org-id-open)
      = ("eww" :follow org-eww-open :store org-eww-store-link) ("rmail" :follow or= g-rmail-open :store org-rmail-store-link)
   &= nbsp;   ("mhe" :follow org-mhe-open :store org-mhe-store-link)
       ("irc" :follow org-irc-vis= it :store org-irc-store-link :export org-irc-export)
 &n= bsp;     ("info" :follow org-info-open :export org-info= -export :store org-info-store-link)
    &= nbsp;  ("gnus" :follow org-gnus-open :store org-gnus-store-link)
       ("docview" :follow org-docvie= w-open :export org-docview-export :store org-docview-store-link)
<= div>       ("bibtex" :follow org-bibtex-open = :store org-bibtex-store-link)
     &= nbsp; ("bbdb" :follow org-bbdb-open :export org-bbdb-export :complete org-b= bdb-complete-link :store org-bbdb-store-link)
  &nb= sp;    ("w3m" :store org-w3m-store-link) ("file+sys") ("file= +emacs") ("shell" :follow org-link--open-shell)
  &= nbsp;    ("news" :follow #[514 "\301\300\302=04Q=02\"\207" [= "news" browse-url ":"] 6 "\n\n(fn URL ARG)"])
  &nb= sp;    ("mailto" :follow #[514 "\301\300\302=04Q=02\"\207" [= "mailto" browse-url ":"] 6 "\n\n(fn URL ARG)"])
  &= nbsp;    ("https" :follow #[514 "\301\300\302=04Q=02\"\207" = ["https" browse-url ":"] 6 "\n\n(fn URL ARG)"])
  &= nbsp;    ("http" :follow #[514 "\301\300\302=04Q=02\"\207" [= "http" browse-url ":"] 6 "\n\n(fn URL ARG)"])
  &nb= sp;    ("ftp" :follow #[514 "\301\300\302=04Q=02\"\207" ["ft= p" browse-url ":"] 6 "\n\n(fn URL ARG)"])
   &= nbsp;   ("help" :follow org-link--open-help) ("file" :complete or= g-link-complete-file)
       ("= elisp" :follow org-link--open-elisp) ("doi" :follow org-link--open-doi))
org-latex-format-headline-function 'org-latex-format-headline-d= efault-function
org-latex-logfiles-extensions '("lof" "lot" "= tex~" "aux" "idx" "log" "out" "toc" "nav" "snm" "vrb" "dvi" "fdb_latexmk" "= blg" "brf" "fls"
"entoc" "ps" "spl" "bbl")
org-= link-elisp-confirm-function 'yes-or-no-p
org-latex-format-inl= inetask-function 'org-latex-format-inlinetask-default-function
org-html-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)= "]
org-html-format-headline-function 'org-html-format-headlin= e-default-function
org-confirm-babel-evaluate nil
org-fontify-whole-block-delimiter-line nil
)

------=_Part_194117_563920015.1617385211814--